VBA to run executable on remote machines (On Domain) (1 Viewer)

Tango

DB/Application Dev Newbie
Local time
Today, 15:30
Joined
Jun 23, 2011
Messages
141
Up until now I have been using remote desktop to log on to close to 500 machines on our domain and running a single executable that requires no input or interaction from me. I would like to know if anyone has seen any scripts to do such a thing automaticly.

The closest I found so far was a vbs file attached below.

Code:
'  Variable Declarations
Dim strRemotePC, objLocator, objService, objWMIService
Dim szTzKey, process, processid, result, strUpdateCommand
' Enter the timeZone you wish to set here. If the name contains spaces, it must be in quotes
szTzKey = "Mountain Standard Time"
On Error Resume Next
'  Main
strRemotePC = InputBox("Enter the computer name. ")
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer(strRemotePC, "Root\DEFAULT")
If Err.Number <> 0 Then
   WScript.Echo "Unable to connect to " & strRemotePC & ", Error " & Err.Number & "," & Err.Description
   Err.Clear
 Else
 Set process = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strRemotePC & "\root\cimv2:Win32_process")
' Add time change privilege to the process object
 process.Security_.Privileges.AddAsString "SeSystemTimePrivilege",True
 strUpdateCommand = "control.exe timedate.cpl,,/Z" & szTzKey
 'Launch control.exe to refresh time zone information using the TZ key name obtained above 
 result = process.create(strUpdateCommand,Null,Null,processid)
 If result <> 0 Then
    Wscript.Echo "Error " & result & "Occurred"
    Wscript.Quit 0
    Else
    Wscript.Echo "Control.exe started with process ID of " & processid & "."
 End If
End If
 

mdlueck

Sr. Application Developer
Local time
Today, 15:30
Joined
Jun 23, 2011
Messages
2,631
I seem to recall SysInternals having a tool to run a command line upon another node connected to the same NT domain. The tool itself is also command line based.

Another method would be to install a Windows Service program which acts like a rexecd. Then from a central / trusted machine, you could rexec (tell) nodes to run a given command line. Google turned up many hits about this sort of thing.
 

Users who are viewing this thread

Top Bottom