gcue Posted July 12, 2010 Posted July 12, 2010 i am trying to schedule a task using schtaskshere 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" commandany of you come across something similar?
Xenobiologist Posted July 12, 2010 Posted July 12, 2010 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
ichigo325 Posted July 12, 2010 Posted July 12, 2010 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]
Somerset Posted July 12, 2010 Posted July 12, 2010 looks like you are trying to send quotes? write out exactly what you want run as if you were in commandline.
Tvern Posted July 12, 2010 Posted July 12, 2010 (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 July 12, 2010 by Tvern
gcue Posted July 12, 2010 Author Posted July 12, 2010 Tvern, that worked!!! without the single quotes around 'cmd ....enc.txt' many thanks!!!!!!!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now