Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

Hey,

 

So I found this syntax example on a microsoft website for schtasks (https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/schtasks.mspx?mfr=true)

 

schtasks /create /tn TaskName /tr TaskRun /sc minute [/mo {1 - 1439}] [/st StartTime] [/sd StartDate] [/ed EndDate] [/s computer [/u [domain\]user /p password]]

It goes into a bit more detail on the webpage but I was wondering if any one knows how to set it so it creates the scheduled task with the highest privileges and run whether a user is logged in as it doesn't have that on any of the examples.

 

Thanks in advance :D

Posted

Just in case any one else comes across this issue. When you have an executable or a batch script some where that has spaces in the path, there's a weird little thing you need to do.

 

So normally you would expect it to be something like;

SchTasks /Create /RL HIGHEST /SC WEEKLY /D MON,TUE,WED,THU,FRI /TN "SQLBackup" /TR "D:\Program Files\Microsoft SQL Server\MSSQL12.SIMS2014\MSSQL\binn\sqlbackups.bat" /ST 01:00 /ru user.name /rp password

 

The above won't work, you need to add in a a couple extra " and a \ so that it looks like;

SchTasks /Create /RL HIGHEST /SC WEEKLY /D MON,TUE,WED,THU,FRI /TN "SQLBackup" /TR ""D:\Program Files\Microsoft SQL Server\MSSQL12.SIMS2014\MSSQL\binn\sqlbackups.bat"" /ST 01:00 /ru user.name /rp password

 

This creates the scheduled task pointing to the path enclosed with " and means that it works perfectly fine.

 

Just thought I would post this on here in case any one else comes across it.

Posted

SchTasks /Create /RL HIGHEST /SC WEEKLY /D MON,TUE,WED,THU,FRI /TN "SQLBackup" /TR ""D:\Program Files\Microsoft SQL Server\MSSQL12.SIMS2014\MSSQL\binn\sqlbackups.bat"" /ST 01:00 /ru user.name /rp password

 

That is meant to be;

SchTasks /Create /RL HIGHEST /SC WEEKLY /D MON,TUE,WED,THU,FRI /TN "SQLBackup" /TR ""D:\Program Files\Microsoft SQL Server\MSSQL12.SIMS2014\MSSQL\binn\sqlbackups.bat"" /ST 01:00 /ru user.name /rp password

 

with the ""D:\ the backslash before the file path is pretty important lol

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...