I found a little vbs script that works great and does exactly what i needed.
I dont remember where i found it but the creator's name is in it.
'ReRun
' Written by Martin Krolik (martin@krolikconsulting.com)
' Copyright 2003
' You are free to use this script for commercial and non-commercial purposes at your own risk.
' No guarantee is given or implied.
' testpass explorer
Set objArgs = Wscript.Arguments
If objArgs.Count < 5 Then
Wscript.Echo "ReRun.vbs: " & Chr(13) & Chr(10) & "Starts a application on a remote machine (desktop)" & Chr(13) & Chr(10) _
& "At least 5 arguments are required : usage ReRun.vbs COMPUTER HOURMINUTE USER PASSWORD COMMANDLINE [COMMANDLINEARGS] " & Chr(13) & Chr(10) _
& "Example: ReRun.vbs TheBoss 1305 mark passWord notepad.exe " & Chr(13) & Chr(10) _
& " (Will kick off notepad on the users desktop at 1:05 pm (scheduled as user mark)" & Chr(13) & Chr(10) _
& " " & Chr(13) & Chr(10) _
& "Written by Martin Krolik (martin@krolikconsulting.com) " & Chr(13) & Chr(10) _
& "Copyright 2003" & Chr(13) & Chr(10) _
& "You are free to use this script for commercial and non-commercial purposes at your own risk." & Chr(13) & Chr(10) _
& "No gaurantees are given or implied." & Chr(13) & Chr(10) _
Else
strComputer = objArgs(0)
strHourMinute = objArgs(1)
strUserId = objArgs(2)
strPassword = objArgs(3)
strCommand = """" & objArgs(4) & """"
blnGetCurrentTime = False
If strHourMinute = "proc" Then
strMode = "Process" ' can not be interactive with desktop due to security reasons
Else
If strHourMinute = "now" Then
blnGetCurrentTime = True
End If
strMode = "Scheduled At Job" ' Will be interactive with the desktop
End If
If objArgs.Count > 5 Then
For I = 5 to objArgs.Count - 1
strCommand = strCommand & objArgs(I) & " "
Next
End If
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
If strUserId = "identify" Then
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'Set objWMIService = objLocator.ConnectServer(strComputer, "root\cimv2")
'objWMIService.Security_.ImpersonationLevel = 2
Else
Set objWMIService = objLocator.ConnectServer(strComputer, "root\cimv2", strUserID, strPassword)
objWMIService.Security_.ImpersonationLevel = 3
End If
If objWMIService is Nothing Then
Wscript.Echo "Could not establish connection to specified computer."
Else
If strMode = "Process" Then
Set objNewProcess = objWMIService.Get("Win32_Process")
errProcessCreated = objNewProcess.Create(strCommand, null, null, intProcessID)
If errProcessCreated <> 0 Then
Wscript.Echo "Error in process creation"
Else
Wscript.Echo "Process created"
End If
Else
Set colItems = objWMIService.ExecQuery("Select * from Win32_TimeZone")
For Each objItem in colItems
strBias = objItem.Bias
Next
If blnGetCurrentTime = True Then
objDate = DateAdd("n", 1, Now)
strHourMinuteSecond = FixedLengthNumber(Hour(objDate),2) & FixedLengthNumber(Minute(objDate),2) & FixedLengthNumber(Second(objDate),2)
strTime = "********" & strHourMinuteSecond & ".000000" & strBias
Else
strTime = "********" & strHourMinute & "00.000000" & strBias
End If
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create (strCommand, strTime, False, 0, , True, JobID)
If errJobCreated <> 0 Then
Wscript.Echo "Error on task creation"
Else
Wscript.Echo "Task created"
End If
End If
End If
End If
Function FixedLengthNumber(vNumber, vLength)
' Prepends an integer with zeros so that the resulting string is of a minumum length
Dim vTemp, n
If Len(vNumber) < vLength then
vTemp = ""
For n = 1 to (vLength - Len(vNumber))
vTemp = vTemp & "0"
Next
FixedLengthNumber = vTemp & vNumber
Else
FixedLengthNumber = vNumber
End If
End Function