When I use the GUI Task Scheduler, I can easily check the "Run with highest privileges" checkbox.
I found no such option in the SchTasks command line too, however.
Is there a way to do that from the command line?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
To add to @Skatterbrainz's answer: If you run the same command/script on XP/2003, specifying /RL, SchTasks.exe will fail to create the task.
You can make a script that will work on XP, 2003, Vista, 2008, 7, 2008R2 etc., by pulling the OS version from the registry. A batch script could look like this:
setlocal set runlevel= REM Get OS version from registry for /f "tokens=2*" %%i in ('reg.exe query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "CurrentVersion"') do set os_ver=%%j REM Set run level (for Vista or later - version 6) if /i "%os_ver:~,1%" GEQ "6" set runlevel=/rl HIGHEST REM Execute SchTasks.exe schtasks.exe /create /tn "Task Name" /sc ONSTART /TR "C:\Scripts\somescript.cmd" /ru SYSTEM %runlevel%