Jump to content

schtasks doesn't run programs with spaces


Recommended Posts

Guest Jonathan Miller
Posted

I need to use the schtasks.exe to create a new scheduled task. One of the

parameters allows you to specify the filename. The file I want to run is in

the Program Files folder. I specify the path, the task gets created but will

not run! The only way to fix it is to open the properties of the task in the

GUI and add double quotes around the whole path! Is there an escape sequence

or something I can use in the command line so that the quotes stay on the

file name?

 

Here is what I'm doing:

 

schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR "C:\Program

Files\Test\Test.exe" /RU SYSTEM

 

As you can see I have double quotes around the path so that the commandline

recognizes it as one parameter. However, when the task is created the double

quotes are stripped off the filename stored with the task. Then when I try

to run the task it won't run because it needed those double quotes. Any

suggestions would be appreciated here.

  • Replies 7
  • Created
  • Last Reply
Guest SBS Rocker
Posted

Re: schtasks doesn't run programs with spaces

 

Take your command line and insert it into a text file and save it as a .bat

file. Use the Task Scheduler to run the bat file.

 

 

"Jonathan Miller" <webmaster at accs dot net> wrote in message

news:3AC649EB-1224-4CC5-9DD9-18C9F4A6C899@microsoft.com...

>I need to use the schtasks.exe to create a new scheduled task. One of the

> parameters allows you to specify the filename. The file I want to run is

> in

> the Program Files folder. I specify the path, the task gets created but

> will

> not run! The only way to fix it is to open the properties of the task in

> the

> GUI and add double quotes around the whole path! Is there an escape

> sequence

> or something I can use in the command line so that the quotes stay on the

> file name?

>

> Here is what I'm doing:

>

> schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR "C:\Program

> Files\Test\Test.exe" /RU SYSTEM

>

> As you can see I have double quotes around the path so that the

> commandline

> recognizes it as one parameter. However, when the task is created the

> double

> quotes are stripped off the filename stored with the task. Then when I

> try

> to run the task it won't run because it needed those double quotes. Any

> suggestions would be appreciated here.

>

Guest Pegasus \(MVP\)
Posted

Re: schtasks doesn't run programs with spaces

 

 

"Jonathan Miller" <webmaster at accs dot net> wrote in message

news:3AC649EB-1224-4CC5-9DD9-18C9F4A6C899@microsoft.com...

>I need to use the schtasks.exe to create a new scheduled task. One of the

> parameters allows you to specify the filename. The file I want to run is

> in

> the Program Files folder. I specify the path, the task gets created but

> will

> not run! The only way to fix it is to open the properties of the task in

> the

> GUI and add double quotes around the whole path! Is there an escape

> sequence

> or something I can use in the command line so that the quotes stay on the

> file name?

>

> Here is what I'm doing:

>

> schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR "C:\Program

> Files\Test\Test.exe" /RU SYSTEM

>

> As you can see I have double quotes around the path so that the

> commandline

> recognizes it as one parameter. However, when the task is created the

> double

> quotes are stripped off the filename stored with the task. Then when I

> try

> to run the task it won't run because it needed those double quotes. Any

> suggestions would be appreciated here.

>

 

You basically gave the answer yourself: Add more quotes to compensate

for the stripped ones.

schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR """"C:\Program

Files\Test\Test.exe"""" /RU SYSTEM

Guest Jonathan Miller
Posted

Re: schtasks doesn't run programs with spaces

 

So it takes four sets of quotes?!? I tried 2 and even 3, but not four.

Thanks!

 

"Pegasus (MVP)" wrote:

>

> "Jonathan Miller" <webmaster at accs dot net> wrote in message

> news:3AC649EB-1224-4CC5-9DD9-18C9F4A6C899@microsoft.com...

> >I need to use the schtasks.exe to create a new scheduled task. One of the

> > parameters allows you to specify the filename. The file I want to run is

> > in

> > the Program Files folder. I specify the path, the task gets created but

> > will

> > not run! The only way to fix it is to open the properties of the task in

> > the

> > GUI and add double quotes around the whole path! Is there an escape

> > sequence

> > or something I can use in the command line so that the quotes stay on the

> > file name?

> >

> > Here is what I'm doing:

> >

> > schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR "C:\Program

> > Files\Test\Test.exe" /RU SYSTEM

> >

> > As you can see I have double quotes around the path so that the

> > commandline

> > recognizes it as one parameter. However, when the task is created the

> > double

> > quotes are stripped off the filename stored with the task. Then when I

> > try

> > to run the task it won't run because it needed those double quotes. Any

> > suggestions would be appreciated here.

> >

>

> You basically gave the answer yourself: Add more quotes to compensate

> for the stripped ones.

> schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR """"C:\Program

> Files\Test\Test.exe"""" /RU SYSTEM

>

>

>

Guest Jonathan Miller
Posted

Re: schtasks doesn't run programs with spaces

 

Okay! The four sets of quotes worked. Now the problem I have is putting

parameters in there. There parameters can't be inside of the quotes that

show up in the schedule task. However, they do need to be contained in

quotes in the command-line so it knows that it all goes together. All of my

attempts have failed so far. Any ideas?

 

"Pegasus (MVP)" wrote:

>

> "Jonathan Miller" <webmaster at accs dot net> wrote in message

> news:3AC649EB-1224-4CC5-9DD9-18C9F4A6C899@microsoft.com...

> >I need to use the schtasks.exe to create a new scheduled task. One of the

> > parameters allows you to specify the filename. The file I want to run is

> > in

> > the Program Files folder. I specify the path, the task gets created but

> > will

> > not run! The only way to fix it is to open the properties of the task in

> > the

> > GUI and add double quotes around the whole path! Is there an escape

> > sequence

> > or something I can use in the command line so that the quotes stay on the

> > file name?

> >

> > Here is what I'm doing:

> >

> > schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR "C:\Program

> > Files\Test\Test.exe" /RU SYSTEM

> >

> > As you can see I have double quotes around the path so that the

> > commandline

> > recognizes it as one parameter. However, when the task is created the

> > double

> > quotes are stripped off the filename stored with the task. Then when I

> > try

> > to run the task it won't run because it needed those double quotes. Any

> > suggestions would be appreciated here.

> >

>

> You basically gave the answer yourself: Add more quotes to compensate

> for the stripped ones.

> schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR """"C:\Program

> Files\Test\Test.exe"""" /RU SYSTEM

>

>

>

Guest Meinolf Weber (Myweb)
Posted

Re: schtasks doesn't run programs with spaces

 

Hello Jonathan Miller webmaster at accs dot net,

 

Did you try to change it like:

 

schtasks /create /RU SYSTEM /SC DAILY /ST 02:30:00 /TN test /TR """"C:\Program

Files\Test\Test.exe""""

 

Best regards

 

Meinolf Weber (Myweb)

Disclaimer: This posting is provided "AS IS" with no warranties, and confers

no rights.

> Okay! The four sets of quotes worked. Now the problem I have is

> putting parameters in there. There parameters can't be inside of the

> quotes that show up in the schedule task. However, they do need to be

> contained in quotes in the command-line so it knows that it all goes

> together. All of my attempts have failed so far. Any ideas?

>

> "Pegasus (MVP)" wrote:

>

>> "Jonathan Miller" <webmaster at accs dot net> wrote in message

>> news:3AC649EB-1224-4CC5-9DD9-18C9F4A6C899@microsoft.com...

>>

>>> I need to use the schtasks.exe to create a new scheduled task. One

>>> of the

>>> parameters allows you to specify the filename. The file I want to

>>> run is

>>> in

>>> the Program Files folder. I specify the path, the task gets created

>>> but

>>> will

>>> not run! The only way to fix it is to open the properties of the

>>> task in

>>> the

>>> GUI and add double quotes around the whole path! Is there an escape

>>> sequence

>>> or something I can use in the command line so that the quotes stay

>>> on the

>>> file name?

>>> Here is what I'm doing:

>>>

>>> schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR "C:\Program

>>> Files\Test\Test.exe" /RU SYSTEM

>>>

>>> As you can see I have double quotes around the path so that the

>>> commandline

>>> recognizes it as one parameter. However, when the task is created

>>> the

>>> double

>>> quotes are stripped off the filename stored with the task. Then

>>> when I

>>> try

>>> to run the task it won't run because it needed those double quotes.

>>> Any

>>> suggestions would be appreciated here.

>> You basically gave the answer yourself: Add more quotes to compensate

>> for the stripped ones.

>> schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR """"C:\Program

>> Files\Test\Test.exe"""" /RU SYSTEM

Guest Jonathan Miller
Posted

Re: schtasks doesn't run programs with spaces

 

Yes I did. That works great if you don't want to pass any parameters to the

program you are running with the scheduled task. So if my test.exe requires

a /input=test.txt paramter it doesn't work.

 

"Meinolf Weber (Myweb)" wrote:

> Hello Jonathan Miller webmaster at accs dot net,

>

> Did you try to change it like:

>

> schtasks /create /RU SYSTEM /SC DAILY /ST 02:30:00 /TN test /TR """"C:\Program

> Files\Test\Test.exe""""

>

> Best regards

>

> Meinolf Weber (Myweb)

> Disclaimer: This posting is provided "AS IS" with no warranties, and confers

> no rights.

>

> > Okay! The four sets of quotes worked. Now the problem I have is

> > putting parameters in there. There parameters can't be inside of the

> > quotes that show up in the schedule task. However, they do need to be

> > contained in quotes in the command-line so it knows that it all goes

> > together. All of my attempts have failed so far. Any ideas?

> >

> > "Pegasus (MVP)" wrote:

> >

> >> "Jonathan Miller" <webmaster at accs dot net> wrote in message

> >> news:3AC649EB-1224-4CC5-9DD9-18C9F4A6C899@microsoft.com...

> >>

> >>> I need to use the schtasks.exe to create a new scheduled task. One

> >>> of the

> >>> parameters allows you to specify the filename. The file I want to

> >>> run is

> >>> in

> >>> the Program Files folder. I specify the path, the task gets created

> >>> but

> >>> will

> >>> not run! The only way to fix it is to open the properties of the

> >>> task in

> >>> the

> >>> GUI and add double quotes around the whole path! Is there an escape

> >>> sequence

> >>> or something I can use in the command line so that the quotes stay

> >>> on the

> >>> file name?

> >>> Here is what I'm doing:

> >>>

> >>> schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR "C:\Program

> >>> Files\Test\Test.exe" /RU SYSTEM

> >>>

> >>> As you can see I have double quotes around the path so that the

> >>> commandline

> >>> recognizes it as one parameter. However, when the task is created

> >>> the

> >>> double

> >>> quotes are stripped off the filename stored with the task. Then

> >>> when I

> >>> try

> >>> to run the task it won't run because it needed those double quotes.

> >>> Any

> >>> suggestions would be appreciated here.

> >> You basically gave the answer yourself: Add more quotes to compensate

> >> for the stripped ones.

> >> schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR """"C:\Program

> >> Files\Test\Test.exe"""" /RU SYSTEM

>

>

>

Guest Meinolf Weber (Myweb)
Posted

Re: schtasks doesn't run programs with spaces

 

Hello Jonathan Miller webmaster at accs dot net,

 

Ok, but the /RU system is used from schtasks not from your test.exe So the

parameter for test.eex has to be specified also in the quotes for me.

 

Best regards

 

Meinolf Weber (Myweb)

Disclaimer: This posting is provided "AS IS" with no warranties, and confers

no rights.

> Yes I did. That works great if you don't want to pass any parameters

> to the program you are running with the scheduled task. So if my

> test.exe requires a /input=test.txt paramter it doesn't work.

>

> "Meinolf Weber (Myweb)" wrote:

>

>> Hello Jonathan Miller webmaster at accs dot net,

>>

>> Did you try to change it like:

>>

>> schtasks /create /RU SYSTEM /SC DAILY /ST 02:30:00 /TN test /TR

>> """"C:\Program Files\Test\Test.exe""""

>>

>> Best regards

>>

>> Meinolf Weber (Myweb)

>> Disclaimer: This posting is provided "AS IS" with no warranties, and

>> confers

>> no rights.

>>> Okay! The four sets of quotes worked. Now the problem I have is

>>> putting parameters in there. There parameters can't be inside of

>>> the quotes that show up in the schedule task. However, they do need

>>> to be contained in quotes in the command-line so it knows that it

>>> all goes together. All of my attempts have failed so far. Any

>>> ideas?

>>>

>>> "Pegasus (MVP)" wrote:

>>>

>>>> "Jonathan Miller" <webmaster at accs dot net> wrote in message

>>>> news:3AC649EB-1224-4CC5-9DD9-18C9F4A6C899@microsoft.com...

>>>>

>>>>> I need to use the schtasks.exe to create a new scheduled task.

>>>>> One

>>>>> of the

>>>>> parameters allows you to specify the filename. The file I want to

>>>>> run is

>>>>> in

>>>>> the Program Files folder. I specify the path, the task gets

>>>>> created

>>>>> but

>>>>> will

>>>>> not run! The only way to fix it is to open the properties of the

>>>>> task in

>>>>> the

>>>>> GUI and add double quotes around the whole path! Is there an

>>>>> escape

>>>>> sequence

>>>>> or something I can use in the command line so that the quotes stay

>>>>> on the

>>>>> file name?

>>>>> Here is what I'm doing:

>>>>> schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR "C:\Program

>>>>> Files\Test\Test.exe" /RU SYSTEM

>>>>>

>>>>> As you can see I have double quotes around the path so that the

>>>>> commandline

>>>>> recognizes it as one parameter. However, when the task is created

>>>>> the

>>>>> double

>>>>> quotes are stripped off the filename stored with the task. Then

>>>>> when I

>>>>> try

>>>>> to run the task it won't run because it needed those double

>>>>> quotes.

>>>>> Any

>>>>> suggestions would be appreciated here.

>>>> You basically gave the answer yourself: Add more quotes to

>>>> compensate

>>>> for the stripped ones.

>>>> schtasks /create /SC DAILY /ST 02:30:00 /TN test /TR """"C:\Program

>>>> Files\Test\Test.exe"""" /RU SYSTEM


×
×
  • Create New...