vraind Posted June 15, 2011 Share Posted June 15, 2011 (edited) I am new to Autoit. I am writing a small script as follows $name = InputBox("File", "Enter a file name") DirCreate($name) RunWait(@WorkingDir &'\7za.exe' & 'a' &'$name' &'$name') The 3rd line is showing error. I want to use the directory created, to be zipped. please help. Edited June 15, 2011 by vraind Link to comment Share on other sites More sharing options...
JohnOne Posted June 15, 2011 Share Posted June 15, 2011 What error is it showing? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Tvern Posted June 15, 2011 Share Posted June 15, 2011 @WorkingDir &'\7za.exe' & 'a' &'$name' &'$name Evaluates to something like: C:\ScriptDir\7za.exea$name$name I think you are looking for something like: @WorkingDir & '\7za.exe a ' & $name & ' ' & $name This adds spaces and replaces the variables with the strings they contain. You probably want to add an extention to the destination archive like this: @WorkingDir & '\7za.exe a ' & $name & ' ' & $name & ".7z" Consolewrite() is usefull for testing when you are concatenating strings like this. If you run the following script you can easily see why your example wouldn't work: Global $name = "Foldername" ConsoleWrite(@WorkingDir &'\7za.exe' & 'a' &'$name' &'$name' & @CRLF) ;original string ConsoleWrite(@WorkingDir & '\7za.exe a ' & $name & ' ' & $name & ".7z" & @CRLF) ;revised string Link to comment Share on other sites More sharing options...
vraind Posted June 15, 2011 Author Share Posted June 15, 2011 @WorkingDir &'\7za.exe' & 'a' &'$name' &'$name Evaluates to something like: C:\ScriptDir\7za.exea$name$name I think you are looking for something like: @WorkingDir & '\7za.exe a ' & $name & ' ' & $name This adds spaces and replaces the variables with the strings they contain. You probably want to add an extention to the destination archive like this: @WorkingDir & '\7za.exe a ' & $name & ' ' & $name & ".7z" Consolewrite() is usefull for testing when you are concatenating strings like this. If you run the following script you can easily see why your example wouldn't work: Global $name = "Foldername" ConsoleWrite(@WorkingDir &'\7za.exe' & 'a' &'$name' &'$name' & @CRLF) ;original string ConsoleWrite(@WorkingDir & '\7za.exe a ' & $name & ' ' & $name & ".7z" & @CRLF) ;revised string Tried the first one.Working fine. Thanks. Link to comment Share on other sites More sharing options...
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