Run Schedules Tasks as SYSTEM

  • Thread starter Thread starter Louis Scholtz
  • Start date Start date
L

Louis Scholtz

Hi All,

I have installed a vbscript to run as a Scheduled Task on several
Windows XP pc's. The pc's are a mixture of SP1's and SP2's. On the SP1
pc's the task would not run at all and the pc's had to be updated to
SP2. On the SP2 machines the task was scheduled by a user with
administrative rights to "Run as: SYSTEM" (we didn't want to schedule
the task with an administrative account as the password could change
frequently.) In 90% of the cases the task ran as expected. However, in
the remaining cases the task would not run and would always report the
status as "Could not start". Does anyone have any experience with this
or any advice on how I can get it to work?

Thanks

Louis
 
Louis,
Louis Scholtz said:
Hi All,

I have installed a vbscript to run as a Scheduled Task on several
Windows XP pc's. The pc's are a mixture of SP1's and SP2's. On the SP1
pc's the task would not run at all and the pc's had to be updated to
SP2. On the SP2 machines the task was scheduled by a user with
administrative rights to "Run as: SYSTEM" (we didn't want to schedule
the task with an administrative account as the password could change
frequently.)

Run a script under the SYSTEM account with mstask?
What strings did you use to enter the credentials in the TaskScheduler
window?
AFAIK there is no way to do that via the GUI, however it can be done with
schtasks.exe
schtasks /create /tn MyScript /ru "SYSTEM" /tr "cscript myvbs.vbs" /sc once
/st 09:00:00

as long as the script does not interact with the desktop it should work.

regards,
tlviewer
 
Created the task through the GUI using the administrator name and
password. Ran the task and then edited the task and replaced "Run as: "
with "SYSTEM" and saved the task. This worked fine on the bilk of the
pc's but not on all. BTW, I included a subroutine in the script to
install the script as a Scheduled task. The script uses schtasks to do
this, but the resulting task would NOT run. Deleting it and adding it
through the GUI would though??? any ideas?

'***************************************************************
'* Subroutine to schedule script as Windows Task. *
'***************************************************************
Sub Install

If OSVersion = "5.1" Then

Dim TaskText

TaskText = "schtasks /Create /tn " & Chr(34) & "Reset " & _
"Inform" & Chr(34)
TaskText = TaskText & " /tr " & Chr(34) & _
WScript.ScriptFullName & Chr(34)
TaskText = TaskText & " /sc " & Chr(34) & "HOURLY" & Chr(34)
TaskText = TaskText & " /st " & Chr(34) & "08:30:00" & Chr(34)
TaskText = TaskText & " /mo " & Chr(34) & "4" & Chr(34)
' If Windows 2003, add the duration flag (NOT supported in XP.

oShell.Run(TaskText)

ElseIf OSVersion = "2" Then
Wscript.Echo "Automatic Installation not available on Windows 98."
End If

End Sub
 
Created the task through the GUI using the administrator name and
password. Ran the task and then edited the task and replaced "Run as: "
with "SYSTEM" and saved the task. This worked fine on the bilk of the
pc's but not on all. BTW, I included a subroutine in the script to
install the script as a Scheduled task. The script uses schtasks to do
this, but the resulting task would NOT run. Deleting it and adding it
through the GUI would though??? any ideas?

'***************************************************************
'* Subroutine to schedule script as Windows Task. *
'***************************************************************
Sub Install

If OSVersion = "5.1" Then

Dim TaskText

TaskText = "schtasks /Create /tn " & Chr(34) & "Reset " & _
"Inform" & Chr(34)
TaskText = TaskText & " /tr " & Chr(34) & _
WScript.ScriptFullName & Chr(34)
TaskText = TaskText & " /sc " & Chr(34) & "HOURLY" & Chr(34)
TaskText = TaskText & " /st " & Chr(34) & "08:30:00" & Chr(34)
TaskText = TaskText & " /mo " & Chr(34) & "4" & Chr(34)
' If Windows 2003, add the duration flag (NOT supported in XP.

oShell.Run(TaskText)

Louis,

Suffice it to say that you are working too hard to accomplish as in your
subject line!
schtasks.exe will now run and you will get this message

<quote>
The task will be created under current logged-on user name
("comp\me").

Please enter the run as password for COMP\me: WARNING: When the run
as password is empty, the scheduled task may not run because of the security
policy
</quote>

If you add the flag
/ru "SYSTEM"

you will be in business and all the dancing/dinking around will be
unnecessary -- sheesh.

good luck,
tlviewer
 
Back
Top