Automating XP
Automating Tasks on Windows XP
Contents
Task Scheduler
Top Bottom- can schedule anything that can be run at the command line
- schedule when computer starts
- when I login: runs when anyone logs in
- only admins can schedule tasks with other user accounts
- uses 'run as' capability, and will not therefore run for accounts with blank passwords
- circular logfile located at %systemroot%\schedlgu.txt: marker indicates most recent task
- option to notify missed tasks
- multiple schedules
- advanced menu of scheduled tasks allows you to stop or pause task scheduler
shtasks: command line interface: only available to administrators
schtasks
- /create
- /change
- /delete
- /end
- /query
- /run
- /tn name of task
- /tr name of command
- /sc schedule
- /mo interval
- /st start time
- /rp password
- /ru username: can use /ru System to run as system account. System tasks are always non-interactive
Several behind the scenes optimisations rely on Task Scheduler to improve disk layout, boot time and application launch time.
Offline Web Pages are synchronised when you choose synchronise from the Tools menu. Can also be scheduled. Edit an existing schedule to get more detailed control.
Batch Commands
Top Bottom| Command | Explanation |
|---|---|
| @ | prevents the line being displayed |
| Echo [Off|On] | |
| Echo msg | |
| Echo. | displays blank line |
| REM msg | |
| :: msg | non-echoed comment |
| If not Errorlevel num cmd | num or greater |
| if not exist file cmd | |
| if not txt1 == txt2 cmd | |
| goto label | |
| :label | |
| for %%var in (set)do [cmd] %%var | |
| shift | %2 becomes %1 |
| call batfile args | |
| setlocal | makes env vars local |
| endlocal | |
| pushd path | saves current folder to stack and changes to path |
| popd | |
| pause | suspends until key is pressed |
| title | set title |
| %appdata% %commonprogramfiles% %comspec% %homedrive% %homepath% %OS% %path% %programfiles% %systemdrive% %systemroot% % temp% %userdomain% %username% %userprofile% %windir% |
env vars |
| >nul | send output to bit bucket |
| for %%t in (wav log ini) do del "%userprofiles%\recent\*.%%t.lnk" |
Windows Script Host
Top BottomWindows Script Host: a host for scripting languages. Run with the help of a language interpreter (e.g. vbscript.dll or jscript.dll). WSH makes ActiveX controls available to scripts.
wscript: gui
cscript: command line
try 'cscript //?'
