How do I specify "Run with highest privileges" in SchTasks?

That's what the /RL option does.

Example: SCHTASKS /Create /TN "New Task" /SC HOURLY /TR blah.exe /RU username /RP password /RL HIGHEST


/RL level Sets the Run Level for the job. Valid values are LIMITED and HIGHEST. The default is LIMITED.


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%