Jump to content

Recommended Posts

Posted

Hi guys,

I know this is something of a Do based problem but I'm asking on here because I want to build it into my autoIT script.

I'm trying to use the _rundos() function to start a program (because its not an executable I can't use Run() ) Below you can see that part of my script:-

_RunDos("start C:\Program Files\HostExplorer.nt\user\hostex\Profile\3270\Default.HEP")

It seems that the script won't work because Dos can't understand the file extension (I assume because of the space after the C:\Program). I've tried defining my path as $file and including that but it didn't work, and also using quotations marks but that also fails (although its likely its the way I'm writing the command causing this to fail)

I was wondering if anybody could tell me the solution to this problem as it is causing a problem anytime I try and use a Dos command in my scripts.

Thanks

Mark

Posted

Hi guys,

I know this is something of a Do based problem but I'm asking on here because I want to build it into my autoIT script.

I'm trying to use the _rundos() function to start a program (because its not an executable I can't use Run() ) Below you can see that part of my script:-

_RunDos("start C:\Program Files\HostExplorer.nt\user\hostex\Profile\3270\Default.HEP")

It seems that the script won't work because Dos can't understand the file extension (I assume because of the space after the C:\Program). I've tried defining my path as $file and including that but it didn't work, and also using quotations marks but that also fails (although its likely its the way I'm writing the command causing this to fail)

I was wondering if anybody could tell me the solution to this problem as it is causing a problem anytime I try and use a Dos command in my scripts.

Thanks

Mark

1. Experiment with single and double quotes like it says in the help file...

2. Do you already have a file association defined for the ".HEP" extension?

Posted

Hi guys,

I know this is something of a Do based problem but I'm asking on here because I want to build it into my autoIT script.

I'm trying to use the _rundos() function to start a program (because its not an executable I can't use Run() ) Below you can see that part of my script:-

_RunDos("start C:\Program Files\HostExplorer.nt\user\hostex\Profile\3270\Default.HEP")

It seems that the script won't work because Dos can't understand the file extension (I assume because of the space after the C:\Program). I've tried defining my path as $file and including that but it didn't work, and also using quotations marks but that also fails (although its likely its the way I'm writing the command causing this to fail)

I was wondering if anybody could tell me the solution to this problem as it is causing a problem anytime I try and use a Dos command in my scripts.

Thanks

Mark

Default.hep is not an executable so DOS will not be able to run it as a program. One good way to test this in future would be to try your command line in a DOS window first. Also DOS does not like spaces and these would need to be inside quotes.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

I've tried putting single and double quotes all over the command and nothing seems to work.

As for the file association, it works when I use the 'Run' box in windows so it should be ok. Unless I need to define a file association in AutoIT, in which case I haven't, how do I do this??

Thanks for helping

Mark

P.S. I apologise for my ignorance with both Dos, Windows and AutoIT!!!

Posted

I've tried putting single and double quotes all over the command and nothing seems to work.

As for the file association, it works when I use the 'Run' box in windows so it should be ok. Unless I need to define a file association in AutoIT, in which case I haven't, how do I do this??

Thanks for helping

Mark

P.S. I apologise for my ignorance with both Dos, Windows and AutoIT!!!

Using the Run box in windows is not the same as running a program at a DOS command prompt.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

Ahh, that I didn't know.

Well surely there is somebody on here that will have launched a program using the _rundos function. Is there anyone that can suggest how to refine the function below:-

_RunDos("start C:\Program Files\HostExplorer.nt\user\hostex\Profile\3270\Default.HEP")

Thanks for your time

Mark

Posted

Ahh, that I didn't know.

Well surely there is somebody on here that will have launched a program using the _rundos function. Is there anyone that can suggest how to refine the function below:-

_RunDos("start C:\Program Files\HostExplorer.nt\user\hostex\Profile\3270\Default.HEP")

Thanks for your time

Mark

This does not use _rundos but it will work

Send("#r")
Send("C:\Program Files\HostExplorer.nt\user\hostex\Profile\3270\Default.HEP")
Send("{Enter}")

And will no doubt provoke better answers.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

Starting the windows dialog box directly. Genius idea (and so simple), much appreciated BigDod. Thankyou for your help

Mark

Here is another attempt

Run(@comspec & ' /c "C:\Program Files\HostExplorer.nt\user\hostex\Profile\3270\Default.HEP"','',@sw_hide)


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

@BigDod

thats how _RunDos does it :o

B)


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

its on the top FAQ list

6. Why can I only use Run() to execute .exe files? What about .msi / .txt and others?

Only a few file extensions are usually "runable" - these are .exe, .bat, .com, .pif. Other file types like .txt and .msi are actually executed with another program. When you double click on a "myfile.msi" file what actually happens in the background is that "msiexec.exe myfile.msi" is executed. So to run a .msi file from AutoIt you would do:

RunWait("msiexec myfile.msi")

Or, an even simpler way is to run the command "start" which will automatically work out how to execute the file for you:

RunWait(@COMSPEC & " /c Start myfile.msi")

thus... maybe this will do the trick

RunWait(@COMSPEC & " /c Start Default.HEP")

8)

NEWHeader1.png

Posted

Hi,

I am not surprised how much trouble there is "getting the quotes right"

I have settled my problem by always using this type of structure to keep the quotes honest;

If StringInStr($File, " ") Then $File = '"' & $File & '"'

If StringInStr($AnswerFile, " ") Then $AnswerFile = '"' & $AnswerFile & '"'

$Command = @ComSpec & " /c " & 'FINDSTR '& $Switches &' '& $File &'>'&$AnswerFile

$DosFINDSTRReturn=RunWait($Command, @SystemDir, @SW_HIDE)

If you really look at "double quotes", they sometimes need to be triple etc.

i would be interested to hear if this solves the problems people have with the quotes, or if you really believe there is some other problem?

Best, randall

Posted

more examples

$rc = _RunDos("for /f %%s in ('dir /b *.dll') do regsvr32 /s %s")

or

$ErrorCode = RunWait( 'Psservice \\' & $line & ' stop "Windows Firewall/Internet Connection Sharing (ICS)"',"",@SW_HIDE)
Posted

Hi guys,

I know this is something of a Do based problem but I'm asking on here because I want to build it into my autoIT script.

I'm trying to use the _rundos() function to start a program (because its not an executable I can't use Run() ) Below you can see that part of my script:-

_RunDos("start C:\Program Files\HostExplorer.nt\user\hostex\Profile\3270\Default.HEP")

It seems that the script won't work because Dos can't understand the file extension (I assume because of the space after the C:\Program). I've tried defining my path as $file and including that but it didn't work, and also using quotations marks but that also fails (although its likely its the way I'm writing the command causing this to fail)

I was wondering if anybody could tell me the solution to this problem as it is causing a problem anytime I try and use a Dos command in my scripts.

Thanks

Mark

If I am not mistaken this slight modification should make it work.

_RunDos('start "C:\Program Files\HostExplorer.nt\user\hostex\Profile\3270\Default.HEP"')

The thing to remember is that if there are spaces in the path then you need quotes around the path. or you could use

$a = FileGetShortName("C:\Program Files\HostExplorer.nt\user\hostex\Profile\3270\Default.HEP")
_RunDos("start " & $a)

FileGetShortName removes all spaces from the path.

Posted

Hi,

@hankjrfan; I think the short names are giving people grief (see other thread)?

more examples

CODE

$rc = _RunDos("for /f %%s in ('dir /b *.dll') do regsvr32 /s %s")

or

CODE

$ErrorCode = RunWait( 'Psservice \\' & $line & ' stop "Windows Firewall/Internet Connection Sharing (ICS)"',"",@SW_HIDE)

Are these problemones or working ones?

I agree with te extra " ' " comment, and it is not clear if some people are using double quotes[""] instead of triple ['"'] , which may look the same on the screen (the second is [' " '] without spaces); hence why I suggest not trying to do it all one one line; use :stringreplace " only if needed for spaces

Best, Randall

Posted

Personally if I need to work with a command line with file and quotes all over the place, I do it this way:

Local $File1 = 'C:\A.EXE'
Local $File2 = 'C:\B.TXT'
Local $File3 = 'C:\Program Files\Filename with Spaces.txt'

Local $Cmd = StringFormat('%s /c "%s" /switch "%s" > "%s"', @ComSpec, $File1, $File2, $File3)
RunWait($Cmd)
Posted

I am not surprised how much trouble there is "getting the quotes right"

Try to create an Autoit script form Autoit and you will find out what fun is, hehe. B)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...