Jump to content

Can someone check where I'm going wrong please?


eben80
 Share

Recommended Posts

Hi all,

I've been using AutoIT quite a bit but first post on here. Sorry it is a problem for a first post :)

I'm trying to have a au3 file created from inside a script but I'm unable to get my nested quoutes etc. sorted out and was hoping someone could tell me where I am going wrong please.

FileWriteLine($script_file, "$Return_Code = RunWait(@ComSpec & "" /c """ & $CMD_var & ", @ScriptDir & ""\Source"", @SW_HIDE, 0) ;" & @CRLF)

$CMD_Var needs to be populated here for use in the second script but the rest stay the same.

Is producing:

$Return_Code = RunWait(@ComSpec & " /c "setup.msi /qr-, @ScriptDir & "\Source", @SW_HIDE, 0) ;

How do I go about using the quotes correctly?

Help appreciated.

Thanks

Link to comment
Share on other sites

Hi, and welcome.

Sorry it is a problem for a first post

Not a problem, Its a help and support forum.

Don't think its a quote problem, there seem to be a missing [&] character in your code.

;your result
$Return_Code = RunWait(@ComSpec & " /c "setup.msi /qr-, @ScriptDir & "\Source", @SW_HIDE, 0)

;what I think your after. ..............!
$Return_Code = RunWait(@ComSpec & " /c " & setup.msi /qr-, @ScriptDir & "\Source", @SW_HIDE, 0)

;corrected, using double qoutes only
ConsoleWrite("$Return_Code = RunWait(@ComSpec & "" /c "" & " & $CMD_var & ", @ScriptDir & ""\Source"", @SW_HIDE, 0) ;" & @CRLF)

;corrected, using both single and double quotes. (less need to use escaped double quotes like [".."".."]
ConsoleWrite('$Return_Code = RunWait(@ComSpec & " /c " & ' & $CMD_var & ', @ScriptDir & "\Source", @SW_HIDE, 0) ;' & @CRLF)

edit:mmm, missing manners.

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Thanks for the reply. Below is actually what I want the output to be for the au3 file:

$Return_Code = RunWait(@ComSpec & " /c " & "setup.msi /qr-", @ScriptDir & "\Source", @SW_HIDE, 0) ;

setup.msi /qr- of course coming from $CMD_Var

Does that make sense? For the life of me I cant get the script to create that line.

Edited by eben80
Link to comment
Share on other sites

Cool that seems like an idea but let me just show in what context it is being used:

$script_file = FileOpen($var & "\Compressed_Source\" & $package_name & ".au3", 10)
                FileWriteLine($script_file, "#include <GUIConstantsEx.au3>")
                FileWriteLine($script_file, "#include <WindowsConstants.au3>" & @CRLF)
                FileWriteLine($script_file, "#include <File.au3>" & @CRLF)
                FileWriteLine($script_file, "#include <7Zip.au3>" & @CRLF)
                FileWriteLine($script_file, "RunWait(@ComSpec & "" /c "" & ""C:\support\packages\" & $package_name & "\7za.exe x C:\support\packages\" & $package_name & "\Source\" & $package_name & ".7z -oC:\support\packages\" & $package_name & "\Source -y"", """", @SW_HIDE, 0) ;" & @CRLF)
                FileWriteLine($script_file, "Sleep(5000)" & @CRLF)
                FileWriteLine($script_file, "$Return_Code = RunWait(@ComSpec & "" /c """ & $CMD_var & ", @ScriptDir & ""\Source"", @SW_HIDE, 0) ;" & @CRLF)
                FileWriteLine($script_file, "" & @CRLF)
                FileWriteLine($script_file, "Sleep(5000)" & @CRLF)
                FileWriteLine($script_file, "DirRemove(""C:\support\packages\" & $package_name & "\Source"", 1)" & @CRLF)
                FileWriteLine($script_file, "Exit($Return_Code)" & @CRLF)
                FileWriteLine($script_file, "" & @CRLF)
                FileClose($script_file)

Can you use the ConsoleWrite to insert lines into a file?

Link to comment
Share on other sites

Can you use the ConsoleWrite to insert lines into a file?

Nope, or at leased not that I now off.

I only use it for passing text to the editor's (scite4autoit) output view for debugging purpose.

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...