Sign in to follow this  
Followers 0
vraind

Input Box

4 posts in this topic

#1 ·  Posted (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 by vraind

Share this post


Link to post
Share on other sites



@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

Share this post


Link to post
Share on other sites

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

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