I want to edit a file on remote servers . Iam using CIM_DATAFILES of WMI for it . I want to run the script with different ID . Below is the code I have written till now.
START CODE
strUser = "abhishek"strPassword = "abcd"
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")Set objWMIService = objwbemLocator.ConnectServer _ (strComputer, "rootcimv2",strUser, strPassword)objWMIService.Security_.authenticationLevel =WbemAuthenticationLevelPktPrivacy
Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Name=C:filesTestg.txt'")
For Each objFile in colFilesWscript.echo "Null hai"Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = objFSO.OpenTextFile("c:Filestestg.txt")abc=objfile.readallwscript.echo abcobjFile.Close
Next
Performing File operation on a file(Remote server
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- enjoyabhi@gmail.com
- Posts: 14
- Last visit: Sun Jan 22, 2012 2:09 am
Performing File operation on a file(Remote server
This is the fourth line:
Set objWMIService = objwbemLocator.ConnectServer _ (strComputer, "rootcimv2",strUser, strPassword)
You did not post the exact error message.
You must be an admistrator. WMUI must be properly installed on remote machine.
Please post complete and clear description of errors whenposting. POsting bits and pieces is not very helpful.
Set objWMIService = objwbemLocator.ConnectServer _ (strComputer, "rootcimv2",strUser, strPassword)
You did not post the exact error message.
You must be an admistrator. WMUI must be properly installed on remote machine.
Please post complete and clear description of errors whenposting. POsting bits and pieces is not very helpful.
- venkat.ram12@gmail.com
- Posts: 6
- Last visit: Tue Jan 17, 2012 5:31 pm
Performing File operation on a file(Remote server
Most of the WMI scripts fail because the target machine is not configured properly. I'm guessing that could be a problem. You can try the below settings in the target machineStart/run "secpol.msc"
Navigate to Local PoliciesSecurity Options
Network Access: Sharing security model for local accounts - Set to Classic
Restart the computer.
Navigate to Local PoliciesSecurity Options
Network Access: Sharing security model for local accounts - Set to Classic
Restart the computer.
- enjoyabhi@gmail.com
- Posts: 14
- Last visit: Sun Jan 22, 2012 2:09 am
Performing File operation on a file(Remote server
I was getting lot of errors So I wrote a script that could modify textfile locally and then I am running it by "Runas" command.