Performing File operation on a file(Remote server

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
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.
This topic is 12 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
enjoyabhi@gmail.com
Posts: 14
Last visit: Sun Jan 22, 2012 2:09 am

Performing File operation on a file(Remote server

Post by enjoyabhi@gmail.com »

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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Performing File operation on a file(Remote server

Post by jvierra »

Your code does nothing. What is your question?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Performing File operation on a file(Remote server

Post by jvierra »

You left out the most important information.
What is your error message and what line is it happening on.

jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Performing File operation on a file(Remote server

Post by jvierra »

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.
User avatar
venkat.ram12@gmail.com
Posts: 6
Last visit: Tue Jan 17, 2012 5:31 pm

Performing File operation on a file(Remote server

Post by venkat.ram12@gmail.com »

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.
User avatar
enjoyabhi@gmail.com
Posts: 14
Last visit: Sun Jan 22, 2012 2:09 am

Performing File operation on a file(Remote server

Post by enjoyabhi@gmail.com »

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.
This topic is 12 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked