#130330 - 2004-11-30 09:33 AM
Re: Trying to Schedule a One-Time Task
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
So what happens? What have you tried?
You'll need to tell us up front, or we will be going around in circles trying to get the information out of you.
A couple of obvious ones to begin with:
- Do the SCHTASKS work if you type them in manually at the command line?
- Once you've run the script have you checked to see if anything has been scheduled?
- Why are you not checking (and displaying) @ERROR and @SERROR after the Shell commands? You will be missing any errors.
|
|
Top
|
|
|
|
#130331 - 2004-11-30 09:35 AM
Re: Trying to Schedule a One-Time Task
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
By default the task can not access network resources so the task would fail.
There are UDFs for scheduling as well.
What clients do you need to support? NT/2000/XP/2003?
What version of KiXtart are you using?
Do your users have Admin rights on their own local systems?
TaskScheduleControl() - Library of UDFs to manage Windows Task Scheduler http://www.kixhelp.com/udfs/udf/83077.htm
Scheduled Task Control Library for JT.EXE http://www.kixhelp.com/udfs/udf/111470.htm
SCHEDULETASK() - Schedules a task on any computer using the Task Scheduler http://www.kixhelp.com/udfs/udf/81888.htm
XP/2003 have a built-in SHUTDOWN command Quote:
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:y y]
No args Display this message (same as -?) -i Display GUI interface, must be the first option -l Log off (cannot be used with -m option) -s Shutdown the computer -r Shutdown and restart the computer -a Abort a system shutdown -m \\computername Remote computer to shutdown/restart/abort -t xx Set timeout for shutdown to xx seconds -c "comment" Shutdown comment (maximum of 127 characters) -f Forces running applications to close without warning -d [u][p]:xx:yy The reason code for the shutdown u is the user code p is a planned shutdown code xx is the major reason code (positive integer less than 256) yy is the minor reason code (positive integer less than 65536)
How To Troubleshoot Scheduled Tasks in Windows XP http://support.microsoft.com/?id=308558
How To Use the Remote Shutdown Tool to Shut Down and Restart a Computer in Windows 2000 http://support.microsoft.com/?id=317371
|
|
Top
|
|
|
|
#130333 - 2004-12-01 06:45 AM
Re: Trying to Schedule a One-Time Task
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
The ForceLogOff works in that it forces the user off of the Server connection as it was intended.
Here is a link that discusses it more.
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/566.mspx
As for the scheduled task not being created, as you have it shown it needs a password which you're not supplying. You can't use /U for the SYSTEM account, you need to use /RU
If that does not correct the issue please let me know, but this works for me, however I don't think you have the time set correctly either as it wants to pretty much run as soon as it is created.
Code:
Break On
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
Dim $MB
$MB=MessageBox("Configuring Automatic Logoff...","Network Security",64,2)
Shell '%COMSPEC% /C schtasks /delete /tn AutoLogoff /f >nul 2>nul'
Shell '%COMSPEC% /C schtasks /create /sc minute /mo 30 /ru System /tn AutoLogoff /tr \\utopia\netlogon\autologoff.bat >nul 2>nul'
|
|
Top
|
|
|
|
#130334 - 2004-12-01 09:37 AM
Re: Trying to Schedule a One-Time Task
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
You missed the third item in the list.
Errors with things like SHELL and RUN will be slient in many scenarios. The only way that you will be able to tell that there was an error is to check and display @ERROR and @SERROR.
Specifically there is a fairly well known problem where %COMSPEC% contains spaces or other characters which cause problems.
You are also ditching any error output from the command using "2>nul", so if there is a problem with the application you won't see the error either.
Get it working first, then silence it.
see how this works for you: Code:
Break On $SO=SetOption('Explicit','On') $SO=SetOption('NoVarsInStrings','On') $SO=SetOption('WrapAtEOL','On') Dim $MB,$sSilence ; ** Uncomment the following line to silence the script once it is working ** ; $sSilence=' >nul 2>nul' $MB=MessageBox("Configuring Automatic Logoff...","Network Security",64,2) If Not $sSilence "Removing old task..."+@CRLF EndIf Shell '"'+%COMSPEC%+'" /C schtasks /delete /tn AutoLogoff /f '+$sSilence ; Note, ignoring errors for this command If Not $sSilence "Creating new logoff task..."+@CRLF EndIf Shell '"'+%COMSPEC%+'" /C schtasks /create /sc minute /mo 30 /ru System /tn AutoLogoff /tr \\utopia\netlogon\autologoff.bat '+$sSilence If @ERROR $MB=MessageBox("Could not create auto logoff task, Reason"+@CRLF+"["+@ERROR+"] "+@SERROR,"Task creation failure") EndIf
The changes wrap the expanded %COMSPEC% value in quotes to avoid problems with spaces, and pop up a message if the add task command fails.
Once you have got the code working to your satisfaction, uncomment the $sSilence=... line to quiten thing down a bit.
|
|
Top
|
|
|
|
#130336 - 2004-12-02 01:49 AM
Re: Trying to Schedule a One-Time Task
|
Anonymous
Anonymous
Unregistered
|
Thanks (everyone)! I will give this a try. I really appreciate the help.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 905 anonymous users online.
|
|
|