Jump to content

Problem with command line arguments and qoutes


benners
 Share

Recommended Posts

I am currently trying to learn to use AutoIt and thought I would try something simple to begin with.

I use a program called DownloadScan that repairs corrupt rar files with par2 sets, my problem is that the commandline usage requires folders with paths in to be enclosed in quotes and this is where I am having problems.

The following code works with folders that have no spaces in the names but I am unable to figure out how to enclose the $CmdLine[2], folder path variable, in quotes so the program runs.

;Set the location of DownloadScan.
$DS = @ProgramFilesDir & "\uA PowerPack\DownloadScan\downloadscan.exe"
;Run DownloadScan with the variables passed to it, $CmdLine[1] = -auto, $CmdLine[2] = Folder path
Run($DS&" "&$CmdLine[1]&" "&$CmdLine[2])
        
;Wait until the windows is active
WinWaitActive("DownloadScan by OtakuCODE")

;Get the text on the status bar .   
$Status = ControlGetText ("DownloadScan by OtakuCODE", "", "WindowsForms10.msctls_statusbar32.app31")

;While the text doesn't equal "Ready.", keep checking the text.
Do
$Status = ControlGetText ("DownloadScan by OtakuCODE", "", "WindowsForms10.msctls_statusbar32.app31")
Until $Status = "Ready."

;Status bar text is "Ready.", assume DownloadScan has completed.
;Delete the redundant .NFO and .Sfv files
FileRecycle($CmdLine[2] & "\*.nfo")
FileRecycle($CmdLine[2] & "\*.sfv")
Exit

I have been searching through the AutoIt forums for an hour but haven't found anything to assist me

Thanks

Link to comment
Share on other sites

if you just want to quote the path to the exe file you could do this

$DS = '"@ProgramFilesDir & "\uA PowerPack\DownloadScan\downloadscan.exe""'

its a single quote then any dubble quote after that will be include in the string and ended with another single quote

Link to comment
Share on other sites

...try something simple...

Welcome to the forum. I think that CmdLineRaw is what you need.

You can read more than you ever wanted to know about it in this thread:

http://www.autoitscript.com/forum/index.ph...=8338&pid=59642

A search of the help file for "CmdLine" yields a topic named "Running Scripts".

That topic is quoted in part here:

So if your script is run like this:

AutoIt3.exe myscript.au3 param1 "this is another param"

$CmdLine[0]equals... 2

$CmdLine[1] equals... param1

$CmdLine[2] equals... this is another param

@ScriptName equals... myscript.au3

In addition to $CmdLine there is a variable called $CmdLineRaw that contains the entire command line unsplit, so for the above example:

$CmdLineRaw equals... myscript.au3 param1 "this is another param"

CmdLine strips the quotes.

CmdLineRaw does not.

:-)

...have fun...

EDIT: Run($DS & " " & $CmdLine[1] & " " & '"' & $CmdLine[2] & '"')

or you could consolidate this part

[1] & " " & '"' & $Cmd

but I'll leave that to you...

or just use CmdLineRaw ;-)

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

@herewasplato

Thank You, I did read the help file and have it constantly open, I used your code and finally went with

Run($DS & " " & $CmdLine[1] & " " & '"' & $CmdLine[2] & '"')

I had tried to use quotes before, not the ' but " and always ended up with "$CmdLine[2]" intead of the path to the folder.

I can not use CmdLineRaw because the $CmdLine[2] variable is always different, the full process is this, due to the fact I cannot program myself I have to use 3rd party tools to attain my goal, a context menu extension called Cmext, introduced to me by a member of this board called MHz provides the right click support and this passes command line arguments to a specified program, in this case DownloadScan. The command line arguments consist of -auto, to automatically start parsing the folder, and the folder location itself, cmext sends these args but it cannot add the quotes as the folder location is added to whateverarguments you specify, so if the arguments were constant that would be easy but as the folder constantly changes. and DownloadScan requires folders with spaces to be enclosed in quotes this is my solution.

Thanks to all whom replied, I am now off to learn a bit more.

Edited by benners
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...