cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Cobra7
Champion Sweeper
First of all I found out I can have the LS tools on the network. So all of my programs start with \\server\share$\. This helps so I do not need to have them on my desktop, and if I needed to change/add anything, other people would not have to re-copy the folder.

Another custom action is this:

If Wscript.Arguments.Count = 0 Then
strComputer = "."
else
strComputer = Wscript.Arguments(0)
end if
strCommand = "notepad.exe"



Const INTERVAL = "n"
Const MINUTES = 1


Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objScheduledJob = objWMIService.Get("Win32_ScheduledJob")
Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime")


objSWbemDateTime.SetVarDate(DateAdd(INTERVAL, MINUTES, Now()))
errReturn = objScheduledJob.Create(strCommand, objSWbemDateTime.Value, False, 0, 0, True, intJobID)


If errReturn = 0 Then
Wscript.Echo "Notepad was started with a process ID: " & intJobID
Else
Wscript.Echo "Notepad could not be started due to error: " & errReturn
End If


What this script does is runs an .exe from your computer to the target computer. Unlike psexec, this will actually run it interactive. The only thing is that it uses the Windows scheduled task so it can take up to 1 minute for it to kick off.

The point is, it can run autoit and .bat files that never seemed to run correctly for me. It can also run files from the network or local PC.

Lansweeper line is:
\\server\share\script.vbs {computer}

If you do not have an argument (i.e. double click) then it will run on the local computer. Change Notepad to whatever .exe you would like.

This script is not my own, I just modified it from http://motevich.blogspot.com/2007/11/execute-program-on-remote-computer.html
2 REPLIES 2
Cobra7
Champion Sweeper
If you use the win32_process method then might as well use psexec.exe. Some of the things I run on remote computers will not run correctlt in the task manager, such as auto-it jobs.

As far as local time I have not tested on our computers in other time zones, but if that does not work I'll see about setting it to run on zulu time, make it simple for all time zones.

As far as the job ID, it doesn't matter to me as long as it runs 🙂
james_mitchell
Engaged Sweeper II
The job ID is not the process ID just the number in the quey of jobs.

Also using your computers local time is not a good idea as your computer time and the remote computer might not be in sync.

I'd recommend using the win32_process method