I'm trying to write a batch script where I can right-click a file and run a command prompt as administrator to run the file (in order to end-run around Windows 10's pickiness about driver files with insufficient certificates). It mostly works so far, but I've struck out on finding help for the last issue.
The script
set d=%DATE%
set t=%TIME%
schtasks /create /tn RunCMD /tr "cmd '%1'" /rl HIGHEST /ru <user> /rp <password> /sc once /st %t:~0,8% /sd %d:~4,10% /v1 /z
schtasks /run /tn RunCMD
pause
The result:
D:\Backup\Drivers>set d=Thu 03/10/2016
D:\Backup\Drivers>set t=12:14:24.29
D:\Backup\Drivers>schtasks /create /tn RunCMD /tr "cmd '"D:\Backup\Drivers\IS_RT2860_W7-5.0.59.0_W8-5.0.59.0_W8Blue-5.0.59.0_W10-5.0.57.0_20150909_5.0.59.0_Free.exe"'" /rl HIGHEST /ru <user> /rp <password> /sc once /st 12:14:24 /sd 03/10/2016 /v1 /z
SUCCESS: The scheduled task "RunCMD" has successfully been created.
D:\Backup\Drivers>schtasks /run /tn RunCMD
SUCCESS: Attempted to run the scheduled task "RunCMD".
D:\Backup\Drivers>pause
Press any key to continue . . .
A new window opens (taskeng.exe, not cmd.exe, which is odd) and it gives me the path that you get when running it as administrator, but it doesn't have any arguments.
C:\WINDOWS\system32>
How do I get the opened command prompt to accept the argument I'm trying to give it?
'
characters