0

I need to read and write(update) some remote machine file.I am able to find the remote file using WMI(System.Management) but not able to do read or updation on that.

Any help would be appreciated.

Thanks

Himanshu

user421719
  • 237
  • 2
  • 7
  • 20
  • Eoin I have already written I am able to find remote file using WMI that should be enough to understand some research has already being done.It's good to share knowledge rather than making harsh comments – user421719 May 17 '12 at 17:08

3 Answers3

3

The WMI doesn't have any class (or method) to read or write the content of files. You may only retrieve the metadata (FileName, Date, Size) of the files using CIM_DataFile, or do tasks like Copy, Rename, Delete or Compress files.

Community
  • 1
  • 1
RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • Yes I have used CIM_Datafile to access the file name but it required to do manipulation on that file.What I need to do...is to access some config to do config setting for the remote windows services.I managed to start /stop remote service using WMI but no luck so far to edit config file for same. – user421719 May 17 '12 at 17:12
  • As my answer says there is not a WMI class to manipulate (edit) the content of a file. So you are out of luck here :( – RRUZ May 17 '12 at 17:21
  • Then FTP download/Upload could be the solution to do so.Any other way? – user421719 May 17 '12 at 17:57
  • Yes FTP is a suitable solution or maybe you can build an additional server application running in the remote machine which allow you to modify the files. – RRUZ May 17 '12 at 18:07
0

RRUZ is correct: WMI cannot copy or create files over a network. This is because it would require credential "hopping": http://msdn.microsoft.com/en-us/library/windows/desktop/aa389288%28v=vs.85%29.aspx

However, a workaround was recently created by Stackoverflow.com user Frank White in C#, and the WMI logic ports directly to VBS. Here's his solution: WMI remote process to copy file

I ported it to a fully working VBScript: https://stackoverflow.com/a/11948096/1569434

Community
  • 1
  • 1
Lizz
  • 1,442
  • 5
  • 25
  • 51
-1

First check your file access in premmisions and set user "Everyone" to Full Control then try it again.Full Access

aliCna
  • 45
  • 6