Sign in to follow this  
Followers 0
bourny

runwait with variables

3 posts in this topic

SlimShady helped me with a runwait with variables earlier... This worked a treat however I have done a similar function in a different script this time using quotes and it fails..

The error I get is not with the variables defined at the top but is with the runwait calling the variables.. Error states system could not find the file specified.

This error is obviously due to an incorrect format in the top two strings ... however if I take the quetes out it mangs on about an error in the variables..

see script below

*************

$a= "@comspec & ' /c find /i "". "

$b= " "" >> C:\analyse\found.txt' "

fileCopy("\\servername\whwash\suffix\suffix.wash", "c:\analyse\suffix.wash", 0)

$suffix_open=FileOpen("c:\analyse\suffix.wash", 0)

If $suffix_open = -1 Then

$date = @MON & "/" & @mday & "/" & @year

$time = "....Time: " & @HOUR & ":" & @MIN

;error - unable to open suffix file

$fail = FileOpen("\\rssncl1dm1\whwash\analyse\analyse.txt", 1)

FileWriteLine($fail, "Mark B: - Whitewash Script Failed - Could not open found.txt)

FileClose($fail)

Exit

EndIf

While 1

$suffix = FileReadLine($suffix_open)

If @error = -1 Then ExitLoop

RunWait($a & $suffix & $b, @scriptdir, @SW_HIDE)

Wend

Bourny

Share this post


Link to post
Share on other sites



SlimShady helped me with a runwait with variables earlier... This worked a treat however I have done a similar function in a different script this time using quotes and it fails..

The error I get is not with the variables defined at the top but is with the runwait calling the variables.. Error states system could not find the file specified.

This error is obviously due to an incorrect format in the top two strings ... however if I take the quetes out it mangs on about an error in the variables..

see script below

*************

$a= "@comspec & ' /c find /i "". "

$b= " "" >> C:\analyse\found.txt' "

fileCopy("\\servername\whwash\suffix\suffix.wash", "c:\analyse\suffix.wash", 0)

$suffix_open=FileOpen("c:\analyse\suffix.wash", 0)

If $suffix_open = -1 Then

$date = @MON & "/" & @mday & "/" & @year

$time = "....Time: " & @HOUR & ":" & @MIN

;error - unable to open suffix file

$fail = FileOpen("\\rssncl1dm1\whwash\analyse\analyse.txt", 1)

FileWriteLine($fail, "Mark B: - Whitewash Script Failed - Could not open found.txt)

FileClose($fail)

Exit

EndIf

While 1

$suffix = FileReadLine($suffix_open)

If @error = -1 Then ExitLoop

RunWait($a & $suffix & $b, @scriptdir, @SW_HIDE)

Wend

Bourny

I don't understand why you make it so complicated. Try this:

CODE
RunWait('@comspec /c find /i ". ' & $suffix & ' " >> C:\analyse\found.txt')

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I don't understand why you make it so complicated. Try this:

RunWait('@comspec /c find /i ". ' & $suffix & ' " >> C:\analyse\found.txt')
You're right, but it might make sense to do it the long way if you are doing it in a loop or function that will be assembling different command lines each time it's run.

In that case, the way to trouble shoot is assemble the whole thing as a variable and check it with a debug message (MsgBox or ConsoleWrite):

; RunWait($a & $suffix & $b, @scriptdir, @SW_HIDE)
$ExtCmd = $a & $suffix & $b
MsgBox(64, "Debug:$ExtCmd", $ExtCmd) ; Temporary debug message
RunWait($ExtCmd, @scriptdir, @SW_HIDE)

Now you can check if the command line is really coming out as intended, pay particular attention to resulting pair of single and double quotes... gets 'em every time.

:rolleyes:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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