Sign in to follow this  
Followers 0
Audrey

Run exe file with multiple quotes and multiple vars

5 posts in this topic

#1 ·  Posted (edited)

Hihi,

Here an example that I can't get it right!

This a command line exe file with more than one double-double quotes and some commands that are used for settings in that exe.

Using the DOS prompt is't working OK:

Start T2P.exe "C:\Program Files\Table\banana.bmp" "C:\Program Files\Table\apple.jpg" -PRB -S35 -CWE -TTE

Now this has to be used in a AutoIt script.

I use the following line and it worked OK as well.

Run(@ComSpec & " /c " & 'Start T2P.exe "C:\Program Files\Table\banana.bmp" "C:\Program Files\Table\apple.jpg" -PRB -S35 -CWE -TTE', "", @SW_SHOW)

Now comes the crazy part:

Some parts has to be variable, like the "C:\Program Files\Table\Pic.jpg" part and "-S35" part.

Because the line is wrapped in single quotes, it turn into gray, which means, this is one big string.

So I think its then not possible anymore to add these extra variables.

I there any one out there who can help me with this? :unsure:

Edited by Audrey

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Ok, so to Use variables inside of quotes you would do something like this:

"c:\Path" & $VARIABLE & "File.txt"

Say $VARIABLE was \Folder1\.

This would mean to Autoit and any commands you pass it would read it as c:\Path\Folder1\File.txt

So in Summary, if you interrupt the quotes and then Add on data with Ampersand, you can accomplish this task.

Edit: Also you would need to Interrupt both sets of Quotes, being ' ' and " ", to do this properly.

Edited by DarkestHour

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

As mentioned take careful note of the quote types and instances and spaces in the command string.

Here is an example concerning your request.

$FileA = '"C:\Program Files\Table\banana.bmp"'
$FileB = '"C:\Program Files\Table\apple.jpg"'
$SwitchParams = "-PRB -S35 -CWE -TTE"
Run('T2P.exe '& $FileA &' '& $FileB &' '& $SwitchParams, "", @SW_SHOW)

Remember that since TIFF2PDF is a console program if its own console window does not remain after it has finished its operations then you will need to capture its output otherwise you will get a brief flash of a console window and thats it.

Edited by Mobius

Share this post


Link to post
Share on other sites

Hi Friends,

Thanks for both for the inputs !!!!! This was very helpful. :unsure::>

I also wanted the "c:\Program Files" part into @ProgramFilesDir and after 30 attempts its working now. ;)

Thanks again!

Audrey

Share this post


Link to post
Share on other sites

Mmm, why do manual quoting if it can be done for you ... when needed.

func QuoteMeIfNeeded($sData)
  if not StringHasSpace($sData) then return
  return '"' & $sData & '"'
endfunc
dim constant $DELIM = ' '
dim $sApplication = 'MyApp.exe'
dim $sFilespec = 'C:\Program Files\Table\apple.jpg'

if not fileExist($sApplication) then Debug_Exit('He!, your calling a executable that''s not there.')

dim $sRunString = QuoteMeIfNeeded($sApplication) & $DELIM & QuoteMeIfNeeded($sFilespec)
debugOut('Used Run() string = ' & $sRunString)
Run($sRunString, "", @SW_SHOW)
More typing, but way less ... attempting.

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

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