PDA

View Full Version : Run a .vbs on a remote PC


mary212
04-16-05, 07:08
Hi,
I'm new to VBscript and trying to get MyProgram.vbs(which is a program that lists all software installed on a PC) to run on a remote PC but it wont do anything....the program runs fine on my local machine and it runs fine if I go onto the remote PC and run it from there but it wont work remotely, any help would be much appreciated...here's the code I have for running a remote program:


'==========================
'Remote.vbs
'==========================

Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Scripts\MyProgram.vbs", _
"\\remoteIPAddress\C$\Scripts\",OverWriteExisting

strComputer = "remoteIPAddress"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")


Error = objWMIService.Create("c:\scripts\MyProgram.vbs", null, null,intProcessID)

If Error = 0 Then
MsgBox (strProcess & " was started with a process ID of " & intProcessID & ".")

Else
MsgBox (strProcess & " could not be started due to error " & _
errReturn & ".")

End If

=================================

So it does copy the program to c:\Scripts of the remote PC but it wont run the program...I do believe that it kicks of a wscript process in the process list on task manager. Please help :)

dedub
05-01-05, 20:55
Without getting into too much detail, you are treading on an area that is touchy. a malicious .vbs script can crush a computer just as fast as the user clicks it. 1000's of viruses have been written with WS scripting. To be able to just run a script remotely would cause caos over every network worldwide. I'm not saying it cannot be done but it's info a new scripter needs to learn on his own.