Sign in to follow this  
Followers 0
zamboni128

RunWait with spaces in directories

9 posts in this topic

I'm trying to run a program that will unzip files to a destination directory. Both the program directory and the destination have spaces in the directory names. I can't not get this to work using runwait but it works from a command line.

If I run the following command from the command line... It works

"cmd /k" "c:\documents and settings\bobh\desktop\esm test\paext.exe" -t "c:\documents and settings\bobh\desktop\esm test\models_update.zip"

If I try the following RunWait, it does not work. It tells me c:\documents is not recognized as an internal or external command.

chr(34) & @COMSPEC & " /k" & chr(34) & " " & Chr(34) & @ScriptDir & "\paext.exe" & chr(34) & " -t " & Chr(34) & @ScriptDir & "\" & $sModelsZipFileName & chr(34)

@ScriptDir = c:\documents and settings\bobh\desktop\esm test

$sModelsZipFileName = models_update.zip

It seems like it can't handle more than one set of "s. I even tried mixing double and single quotes.

Anybody have any ideas?

Thanks in Advance

Share this post


Link to post
Share on other sites



This works on my system:

Local $cmd =  @COMSPEC & " /k dir " & Chr(34) & @DocumentsCommonDir & chr(34) 
    runwait($cmd, @TempDir, @SW_SHOW)

AutoIt version 3.2.11.0

Share this post


Link to post
Share on other sites

This works on my system:

Local $cmd =  @COMSPEC & " /k dir " & Chr(34) & @DocumentsCommonDir & chr(34) 
    runwait($cmd, @TempDir, @SW_SHOW)

AutoIt version 3.2.11.0

This will not always be run from the @DocumentsCommonDir. In most cases it will be run from a temp dir and maybe have spaces in the subdir name.

What I'm trying to do is call a program using the full path and pass it switches, unzip directory and directory of zip file. All using full path names. This requires 3 sets of double quotes and I can't make it work.

Share this post


Link to post
Share on other sites

If my sample works you should compare it to your code. I can not run your code as files are missing on my system. So to create a common ground I used @DocumentsCommonDir as it normally does have spaces in it.

So, what is the biggest difference between the code you provided and the one I provided?

Or: Are you really able to run "cmd /k" (literally including the ") from your run dialog?

Share this post


Link to post
Share on other sites

It tells me c:\documents is not recognized as an internal or external command.

chr(34) & @COMSPEC & " /k" & chr(34) & " " & Chr(34) & @ScriptDir & "\paext.exe" & chr(34) & " -t " & Chr(34) & @ScriptDir & "\" & $sModelsZipFileName & chr(34)

@ScriptDir = c:\documents and settings\bobh\desktop\esm test

$sModelsZipFileName = models_update.zip

It seems like it can't handle more than one set of "s. I even tried mixing double and single quotes.

Anybody have any ideas?

Thanks in Advance

A lot of time you get that message when you don't add the working directory.

RunWait(@ComSpec & ' /k "' & @ScriptDir & '\paext.exe" -t "' & @ScriptDir & '\' & $sModelsZipFileName & '"', @ScriptDir)

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

A lot of time you get that message when you don't add the working directory.

RunWait(@ComSpec & ' /k "' & @ScriptDir & '\paext.exe" -t "' & @ScriptDir & '\' & $sModelsZipFileName & '"', @ScriptDir)
I tried the above command and the results are attached in the document. I still get the problem where it doesn't handle spaces in the command correctly. The second image in the attachment is a msgbox output of the command. It appears to be correct and if executed from a cmd window, works correctly. It only fails when i use it in an autoit script with a runwait command.

Do you have any other ideas?

Thanks

runwait.doc

Share this post


Link to post
Share on other sites

I'm a noob and all, but I'd start at the simplest way first..

Can you run it as such:

Run('"c:\documents and settings\bobh\desktop\esm test\paext.exe" -t "c:\documents and settings\bobh\desktop\esm test\models_update.zip"')

and have it work?

If so, then at least you know it can be done.. and move forward from there. Maybe Im missing something in your question, but well.. maybe this helps too.

Share this post


Link to post
Share on other sites

FileGetShortName

Using FileGetShortName works. Sometimes the simplest solution isn't the most obvious.

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