Jump to content

Recommended Posts

Posted

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?

Posted

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

Posted

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]

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

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...