Sign in to follow this  
Followers 0
ReDFlaG

run & LFN

15 posts in this topic

Hi,

i've almost finished a GUI for a dos32 appz and i've found a bug in my code.

$path='"'&$path&'"'
 $temp=''
 $foo = Run("app.exe /param1="&$num&" /param2="&$path, "", @SW_HIDE, 7)

it's working with path that does not contain space. but if path looks like "c:\program files\test.sav" then it hangs complaining that it can't find the specified files (Unable to execute the external program).

I've tried to add the " using $path=' " ' &$path& ' " ' but doesn't work.

Can someone help?

thanks!

Share this post


Link to post
Share on other sites



Dos chokes on spaces. It interprets the space as end of path and all that follows as additional parameters. You'll notice in shortcuts the path is enclosed in quotes and interpreted correctly.

I'd experiment with creating a shortcut and manipulating that instead.

I'd have to research whether it is com spec or rundll or what you use to launch a shortcut.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Right, it's space that make it hangs, that's why i've added quote at the begining and at the end of my $path var, but even with that it hangs.

When i check into a msgbox, the syntax is correct! When i run it into a dos box to verify it's ok. But when i use autoit run command it hangs.

strange.

PS i could use FileGetShortName but i don't think it's a good idea since the user may have multiple directories begining with the same name

Edited by ReDFlaG

Share this post


Link to post
Share on other sites

Another avenue that I myself will have to explore shortly.

It will work if you can use the 8.3 format.

Thus c:\progra~1\test.sav

I need to find an efficient way to collect the short file paths .

Share this post


Link to post
Share on other sites

Just saw your edit. I'll have to remember FileGetShortName.

I don't understand "multiple directories begining with the same name"

problem since there is only 1 finite path to a particular file.

I'm not familiar with your interface but I assume you envision a problem there.

Perhaps an array of long and short paths would solve the problem

Share this post


Link to post
Share on other sites

program files toto

program files tutu

program files titi

will give

progra~1

progra~2

progra~3

I'm afraid that this will be much more confusing for the end user of my GUI. And anyway i don't want to use 8.3 names since i'm afraid of issues that can "comes" with it. On top of that i really don't understand why my code is not working even when i add the quote to my path.

PS sorry if it's not very clear, my english is quite rusty and it's not my native language.

Share this post


Link to post
Share on other sites

I'm afraid that this will be much more confusing for the end user of my GUI. And anyway i don't want to use 8.3 names since i'm afraid of issues that can "comes" with it.

Why will it be more confusing for the user and why will it cause problems?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

it can cause problem if 8.3 support is disable on (in? for?) a system for example

more confusing.. well "program files" is more clear than progra~1. All user are not aware of this kind of "spelling"

And like i was saying, anyway (forget confusing stuff, forget issue) why is not my code working even when adding ""?

Edited by ReDFlaG

Share this post


Link to post
Share on other sites

well "program files" is more clear than progra~1.

the user can still put in "program files" or browse to it and you can then get the shortname purely for your run command.

Have you tried using Run (@Comspec etc....)

Share this post


Link to post
Share on other sites

tryed @comspec without success.

i've made a filesavedialog box so that user browse, and that's the way i got the full path and the name of the file ex: $path=c:\program files\test.dat

i'll then have to add more code to split the string into $path to then convert it to 8.3

have you an idea why the code is not working even with ""?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

tryed @comspec without success.

i've made a filesavedialog box so that user browse, and that's the way i got the full path and the name of the file ex: $path=c:\program files\test.dat

i'll then have to add more code to split the string into $path to then convert it to 8.3

have you an idea why the code is not working even with ""?

You've tried $path = """c:\program files\test.sav""" yes?

What about using single ' quotes at the begining and end and double " to specify a path

$path = '"c:\program files\test.sav"'

Run ('app.exe /param1='&$num&' /param2='&$path,"")

and also have you specified the run command with specifying the working directory

Edited by ChrisL

Share this post


Link to post
Share on other sites

Have you made sure that the string you want to put together works in a command window? I always make sure it works in the cmd window first, then when I convert to code, it is easier to debug.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

i've tried so much things... here are some that do not work

Run ('app.exe /param1='&$num&' /param2='&$path,"")
Run ("app.exe /param1="&$num&" /param2="&$path,"")
Run(@ComSpec & " /c " & '.\app.exe /param1='&$num&' /param2="'&$path&'"', "", @SW_HIDE,7)

$path='"'&$path&'"'
$foo = Run(@ComSpec & " /c " & '.\app.exe /param1='&$num&' /param2='&$path, "", @SW_HIDE,7)

in a message box i output the syntax and it is correct!!!!

(msgbox says: app.exe /param1=12 /param2="c:\program files\temp\test.dat")

with no space in the path it works!

and of course i've tested the syntax in a pure dos box, typing it myself, and it works. (with space or whithout space in path)

that's why i'm getting mad... i really have tried so much things. i do not understand!!!

Edited by ReDFlaG

Share this post


Link to post
Share on other sites

I remember having this problem with a dos program. In a dos box it worked, but in script it did not (with the exact same text). I could not find anyway around it, or why it did it. I eventually had the program write the command to a .bat file and executed the .bat file and it worked. It was not pretty, but it was the only way I could get it to work. Might be worth trying.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

I FOUND IT!!!!!

here is the working code

$path='"'&$path&'"'
 $foo = Run(@ScriptDir &'\app.exe /param1='&$num&' /param2='&$path, '', @SW_HIDE, 7)

:lmao:

Edited by ReDFlaG

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