Sign in to follow this  
Followers 0
gcue

problem with quotes

8 posts in this topic

i am trying to schedule a task using schtasks

here is what i am trying to set:

RunWait('schtasks /create /s \\hostname /Ru SYSTEM /tn "EncryptionTest" /tr "cmd /c sgestate /l | findstr /i 'Return code' > c:\temp\enc.txt" /sc once /st 00:00:00', "", @SW_HIDE)

using 'Return code' with single quotes creates the task successfully but it wont run it. it wants the double quotes around "Return code"

so if i use double quotes around "Return code", it doesnt like the double quotes nor single quotes around the whole "cmd /c..... /st 00:00:00" command

any of you come across something similar?

Share this post


Link to post
Share on other sites



Hi what about "" when you need " ?


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

yea i tried that too.. no dice.

Share this post


Link to post
Share on other sites

Hmm?? Try this..

RunWait("schtasks /create /s \\hostname /Ru SYSTEM /tn ""EncryptionTest"" /tr ""cmd /c sgestate /l | findstr /i ""Return code"" > c:\temp\enc.txt"" /sc once /st 00:00:00", "", @SW_HIDE)

[size="2"][font="Lucida Sans Unicode"][b][/b][/font][/size]

Share this post


Link to post
Share on other sites

no dice =/

Share this post


Link to post
Share on other sites

looks like you are trying to send quotes? write out exactly what you want run as if you were in commandline.


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This isn't realy an autoit problem. You're trying to send a commandline containing quotes to schtasks, which it doesn't like. I think you'd have the same problem is you tried to type that code out in cmd.

nonetheless, try this:

Local $pid, $line, $string
$string = "schtasks /create /S \\hostname /RU SYSTEM /TN ""EncryptionTest"" /TR ""'cmd /c sgestate /l | findstr /i \""Return code\"" > c:\temp\enc.txt'"" /SC ONCE /ST 00:00:00"
ConsoleWrite($string & @CRLF) ;this is the string with escaped double quotes'
;note "'cmd /c sgestate /l | findstr /i \"Return code\" > c:\temp\enc.txt'" single quotes in doubles for the entire string, schtasks escaped doubles for return code.
$pid = Run($string, "", @SW_HIDE,8)
While 1
    $line &= StdoutRead($pid)
    If @error Then ExitLoop
WEnd
ConsoleWrite($line & @CRLF)

edit: the stdread was just to make it easier for me to see what was going on. You can use that string with runwait if it works.

edit: typo.

Glad it worked gcue. The escaped and embedded quotes where in the help for schtasks (schtasks /create /?), but I couldn't test it on my PC.

Edited by Tvern

Share this post


Link to post
Share on other sites

Tvern, that worked!!!

without the single quotes around 'cmd ....enc.txt'

many thanks!!!!!!!

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0