AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with run, %comspec% where filepathname has spaces
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
corrupt



Joined: 29 Dec 2004
Posts: 2421

PostPosted: Tue Feb 21, 2006 8:04 pm    Post subject: Reply with quote

jroad wrote:
I get your example to work, but not with one of my original requirements, which is that the two parameters must be enclosed in double quotes:
Code:
testprog.exe "param a" "param b"

Unless I'm misunderstanding... try:
Code:
""testprog.exe" "param a" "param b""
Back to top
View user's profile Send private message Visit poster's website
jroad



Joined: 06 Feb 2006
Posts: 26

PostPosted: Tue Feb 21, 2006 9:12 pm    Post subject: Reply with quote

Quote:
Unless I'm misunderstanding... try:
Code:
Code:
""testprog.exe" "param a" "param b""

Yes, I have tried this:
Code:

prog2 = C:\dev\code\ahk\general\ShowParams\ShowParams.ahk
a = C:\Program Files\Foo
b = C:\Nice Path\Bar
Run %comspec% /k ""%prog2%" "%a%" "%b%""

I wasn't very clear with my example. I was trying to show what the line would look like if typed from the command line, not using PhiLho's sample code. So, how would you manipulate the above test code so that PhiLho's ShowParams receives two quoted parameters such as:
Code:
"C:\Program Files\Foo" "C:\Nice Path\Bar"

instead of:
Code:
C:\Program Files\Foo C:\Nice Path\Bar
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2421

PostPosted: Tue Feb 21, 2006 9:38 pm    Post subject: Reply with quote

Here's an example you could use to place quote characters around each item sent:
Code:
prog2 = C:\dev\code\ahk\general\ShowParams\ShowParams.ahk
a = C:\Program Files\Foo
b = C:\Nice Path\Bar
Run %comspec% /c ""%prog2%" "'"'"%a%"'"'" "'"'"%b%"'"'"",, Hide


Although PhiLho's ShowParams test app works, I was lazy...:
Code:
MsgBox, %1%`n%2%`n%3%`n%4%`n%5%`n%6%`n%7%`n%8%`n%9%


BTW... Unless you are intentially trying to leave the cmd window open you may want to use cmd /c and the Hide option instead of using cmd /k . For more info type cmd /? from a cmd prompt and see the Run command in the AHK help file.
Back to top
View user's profile Send private message Visit poster's website
jroad



Joined: 06 Feb 2006
Posts: 26

PostPosted: Tue Feb 21, 2006 11:41 pm    Post subject: Reply with quote

Quote:
Code:
Code:
prog2 = C:\dev\code\ahk\general\ShowParams\ShowParams.ahk
a = C:\Program Files\Foo
b = C:\Nice Path\Bar
Run %comspec% /c ""%prog2%" "'"'"%a%"'"'" "'"'"%b%"'"'"",, Hide 


Please correct me if I'm wrong but it appears the "' pieces are trying to build a double quote from 2 single quotes? If so, that's not what the program will take (I tested it.) On the screen it looks similar but it is not.
Compare:
Code:
MsgBox `'`' or ""


Is that what your code is doing or am I not understanding?
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2421

PostPosted: Tue Feb 21, 2006 11:47 pm    Post subject: Reply with quote

Hmm... you're right. I'll try and play around with it a bit more...
Back to top
View user's profile Send private message Visit poster's website
jroad



Joined: 06 Feb 2006
Posts: 26

PostPosted: Tue Feb 21, 2006 11:51 pm    Post subject: Reply with quote

Quote:
Hmm... you're right. I'll try and play around with it a bit more...

I'm not sure if you got a chance to read all the previous posts, but I have a workaround (shortpaths for target) solution. So, at this point I think the matter is more intellectual curiosity than dire need for solution. In any case, thanks for your input.
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2421

PostPosted: Wed Feb 22, 2006 12:25 am    Post subject: Reply with quote

Anytime Smile . This seems to work ok on my system (WinXP Pro SP2):

Code:

prog2 = C:\dev\code\ahk\general\ShowParams\ShowParams.ahk
a = C:\Program Files\Foo
b = C:\Nice Path\Bar
Run %comspec% /c ""%prog2%" """"%a%"""" """"%b%""""",, Hide


Basically the quote character has to be put in quotes and quotes need to be put around the whole thing. So you end up with 4 quote characters on each side. The first (on left) and last (on right) for each section to enclose the section, three quotes in a row to escape the quote character and the variable content in the middle. Smile
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group