Reputation: 129
So I'm trying to create a scheduled task using batch in a powershell script because I cant use the powershell method, due to the fact that my company is using the outdated windows server 2008. For some reason ISE is not finding the new-scheduledtask
command. Even though I have powershell 4.0 installed and have tried to update the help and nothing works. Here is what i have so far on creating the scheduled task:
&schtasks /create /tn "ExtractSSRSData" /tr "C:\Program Files\company\HTFS.Job.Launcher\HTFS.Common.Job.Launcher.exe" /sc "DAILY"
.
For some reason when this creates the task, the path gets cut in half and part goes into the file path field and the other ends up in the arguments field (as screen shot below). I also don't know the argument to add arguments to a task in batch.
Also i have these arguments that need to go into the add arguments window how do i get them there in batch? SetSSRSDataInDb admin "CompanyCode=company"
Upvotes: 0
Views: 1525
Reputation: 4742
It appears that the command and parameters are parsed from the same string, and it splits the command and parameters at the first non-delimited space.
Delimit the entire string that includes the command and argument in double quotes, and then delimit the path and .exe with single quotes, followed by a space, and then the parameters:
&schtasks /create /tn "ExtractSSRSData" /tr "'C:\Program Files\company\HTFS.Job.Launcher\HTFS.Common.Job.Launcher.exe' SetSSRSDataInDb admin 'CompanyCode=company'" /sc "DAILY"
You can see after running this that if one of the parameters needs to be delimited with quotes (CompanyCode=company
in your example), you just need to use single quotes and it magically delimits the string with double quotes.
Upvotes: 2