Sign in to follow this  
Followers 0
Julien.alkaza

Single and double quotes in path

13 posts in this topic

Hello,

I'm trying to find a solution but I can't!!!

What I want to do is to run a program with parameters :

"C:\Program Files\2BrightSparks\SyncBack\SyncBack.exe" -m "save"

But, it doesn't work!!! It seems to be a quotes problem, but I can't find where!!!

I'serach for 2 hours on the forum but didn't find anything!!!

Thanks for help!!

Oh, my line of code :

RunWait('"C:\Program Files\2BrightSparks\SyncBack\SyncBack.exe" -m "save"', "C:\Program Files\2BrightSparks\SyncBack")

What????????

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Maybe this will work:

RunWait('"' & "C:\Program Files\2BrightSparks\SyncBack\SyncBack.exe" & '"' & " -m " & '"' &  "save" & '"', "C:\Program Files\2BrightSparks\SyncBack")
Edited by Jotun

Share this post


Link to post
Share on other sites

Good idea to use Macro's where suitable. You could try to not using a working directory parameter as well to see if that works, as I see little wrong with your syntax.

RunWait('"' & @ProgramFilesDir & '\2BrightSparks\SyncBack\SyncBack.exe" -m "save"', @ProgramFilesDir & '\2BrightSparks\SyncBack')

Share this post


Link to post
Share on other sites

Thanks!!

But it still doesn't work!!

In fact the application runs but it does not do what I want.

The aim is to synchronise files between My documents and a file server. Configuration is made in a profile called save.

This command works well in a dos shell, but not in autoit.

I've tried your two solutions


What????????

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi,

what about

RunWait(0, '"' & "C:\Program Files\2BrightSparks\SyncBack\SyncBack.exe" _
& '"' & " -m " & '"' &  "save" & '"', '"' & "C:\Program Files\2BrightSparks\SyncBack" & '"' )

I don´t know whether the save command has to be surrounded by quotes.

But if you post your dos-command, we´ll find the solution. :lmao:

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I have tested the line in my last post and works fine (folder to another folder). I also tried the below and that works.

$dir_start = @WorkingDir
$dir_program = @ProgramFilesDir & '\2BrightSparks\SyncBack'
FileChangeDir($dir_program)
RunWait('SyncBack.exe -m "save"')
FileChangeDir($dir_start)

I am not sure of your problem, unless it is something to do with your file server and permissions or something else. :lmao:

-m is the default action so can be left out of the command if desired.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

You may wish to StringFormat() the desired command line - creates nice readable code w/o all the ampersands.

$dir = "c:\program files\2BrightSparks\SyncBack"
$exe = "SyncBack.exe"
$cmd = StringFormat('"%s\\%s" -m save',$dir,$exe)
RunWait($cmd,$dir)

See the StringFormat doc if the \\ is unclear...It might be better to do it this way (untested):

$dir = "c:\program files\2BrightSparks\SyncBack"
$exe = '\' & "SyncBack.exe"
$cmd = StringFormat('"%s%s" -m save',$dir,$exe)
RunWait($cmd,$dir)
Edited by flyingboz

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

If you have lots of switches in a runwait (without the comspec) i have noticed that it will usually fail.

try this

RunWait(@comspec & ' /c "C:\Program Files\2BrightSparks\SyncBack\SyncBack.exe" -m "save"')
Edited by blademonkey

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

I usually use _rundos() for things like this.

Also, when formatting complex dos commands, I use clipput() as a debugging tool, so that whatever you are attempting to run in autoit is pasted to the clipboard.

Try pasting it into a dos window, executing it and see what errors are being thrown up.

Share this post


Link to post
Share on other sites

If you have lots of switches in a runwait (without the comspec) i have noticed that it will usually fail.

try this

RunWait(@comspec & ' /c "C:\Program Files\2BrightSparks\SyncBack\SyncBack.exe" -m "save"')
I'm going to agree with BladeMonkey on this one. His code should work flawlessly. :lmao:

[quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD()

Share this post


Link to post
Share on other sites

I usually use _rundos() for things like this.

Also, when formatting complex dos commands, I use clipput() as a debugging tool, so that whatever you are attempting to run in autoit is pasted to the clipboard.

Try pasting it into a dos window, executing it and see what errors are being thrown up.

Good point.

I personnally use the consolewrite() command for debugging. It goes write into the Scite debug window and is a life saver for Loop issues.


---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

From the help file:

Strings

Strings are enclosed in double-quotes like "this". If you want a string actually contain a double-quote use it twice like:

"here is a ""double-quote"" - ok?"

You can also use single-quotes like 'this' and 'here is a ' 'single-quote' ' - ok?'

You can mix quote types to make for easier working and to avoid having to double-up your quotes to get what you want. For example if you want to use a lot of double-quotes in your strings then you should use single-quotes for declaring them:

'This "sentence" contains "lots" of "double-quotes" does it not?'

is much simpler than:

"This ""sentence"" contains ""lots"" of ""double-quotes"" does it not?"

When evaluated, strings can have Env variables or Var variables substitution according to Opt() function definition.

So: Put the whole lot inside a set of single quotes and see if that does the trick.

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