run script without certain privilege, how?

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hi,

The following script will create a scheduled job on a remote PC, and the
created job will run under Local System account. Currently the script is
triggered by using WMI Event Notification Query on server. Since the job
will run under Local System account, the job creation needs certain
privilege. Is there a way to trigger the script to run from the server by a
Logon Script of an ordinary user who has no local admin power at all? TIA,
Mark



'-----------------------------------------------------------------------------------

'---Create a Scheduled Task on a remote PC to shut it down after
a certain period of time

'-----------------------------------------------------------------------------------

strComputer = "test6"

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")

Set colScheduledTasks = objWMIService.ExecQuery _

("Select * from Win32_ScheduledJob")

For Each objTask in colScheduledTasks

intJobID = objTask.JobID

Set objInstance = objWMIService.Get _

("Win32_ScheduledJob.JobID=" & intJobID)

objInstance.Delete

Next



set wshshell=wscript.createobject("wscript.shell")



strTime=FormatDateTime(DateAdd("n", 125, Now), vbShortTime)



'Australia Eastern Standard Time

'strTime = "********" & mid(strTime,1,2) & mid(strTime,4,2) &
"00.000000+600"



'Australia Eastern Standard Time - Daylight Savings time

strTime = "********" & mid(strTime,1,2) & mid(strTime,4,2) &
"00.000000+660"



strComputer = " test6"

Set objNewJob = objWMIService.Get("Win32_ScheduledJob")

errJobCreated = objNewJob.Create ("shutdown.exe /s /f /t 30",
strTime, , , , , JobId)

If errJobCreated <> 0 Then

'Wscript.Echo "Error on task creation"

Else

'Wscript.Echo "Task created"

End If


.



Relevant Pages

  • Re: run script without certain privilege, how?
    ... The following script will create a scheduled job on a remote PC, ... created job will run under Local System account. ... 'Australia Eastern Standard Time - Daylight Savings time ...
    (microsoft.public.scripting.vbscript)
  • Re: run script without certain privilege, how?
    ... mean to modify the script itself so that the script can be used directly as a logon script? ... The following script will create a scheduled job on a remote PC, and the created job will run under Local System account. ... Is there a way to trigger the script to run from the server by a Logon Script of an ordinary user who has no local admin power at all? ... 'Australia Eastern Standard Time - Daylight Savings time ...
    (microsoft.public.scripting.vbscript)
  • Re: run script without certain privilege, how?
    ... mean to modify the script itself so that the script can be used directly as ... created job will run under Local System account. ... a Logon Script of an ordinary user who has no local admin power at all? ... 'Australia Eastern Standard Time - Daylight Savings time ...
    (microsoft.public.scripting.vbscript)
  • Re: Flexibility of Eventriggers in Win2003 - query on source + wil
    ... I created a very broad event trigger that looks only at entries of /EID ... The event trigger runs a batch file that then calls a vbs script that uses ... Namely to tweak it so that it will check to see if it has sent the admin ...
    (microsoft.public.windows.server.general)
  • Script endlessly looping
    ... The following script has a loop that executes ftp to look for a trigger ... trigger file and renames the data file on the remote server. ...
    (comp.unix.shell)