run script without certain privilege, how?
- From: "Mark" <markxgzhang@xxxxxxxxxxx>
- Date: Sun, 13 Jan 2008 03:04:58 +1100
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
.
- Follow-Ups:
- Re: run script without certain privilege, how?
- From: Richard Mueller [MVP]
- Re: run script without certain privilege, how?
- Prev by Date: IP Range Scanner version 3
- Next by Date: Re: run script without certain privilege, how?
- Previous by thread: Excel And VBScript
- Next by thread: Re: run script without certain privilege, how?
- Index(es):
Relevant Pages
|