locutus243 Posted October 27, 2005 Share Posted October 27, 2005 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 Link to comment Share on other sites More sharing options...
Confuzzled Posted October 27, 2005 Share Posted October 27, 2005 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.ThanksMark1. 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? Link to comment Share on other sites More sharing options...
BigDod Posted October 27, 2005 Share Posted October 27, 2005 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.ThanksMarkDefault.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 Link to comment Share on other sites More sharing options...
locutus243 Posted October 27, 2005 Author Share Posted October 27, 2005 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!!! Link to comment Share on other sites More sharing options...
BigDod Posted October 27, 2005 Share Posted October 27, 2005 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 helpingMarkP.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 Link to comment Share on other sites More sharing options...
locutus243 Posted October 27, 2005 Author Share Posted October 27, 2005 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 Link to comment Share on other sites More sharing options...
BigDod Posted October 27, 2005 Share Posted October 27, 2005 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 timeMarkThis does not use _rundos but it will workSend("#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 Link to comment Share on other sites More sharing options...
locutus243 Posted October 27, 2005 Author Share Posted October 27, 2005 Starting the windows dialog box directly. Genius idea (and so simple), much appreciated BigDod. Thankyou for your help Mark Link to comment Share on other sites More sharing options...
Shibuya Posted October 27, 2005 Share Posted October 27, 2005 u might want to look herehttp://www.autoitscript.com/forum/index.ph...ndpost&p=115180i used the function FileGetShortName to solve the problem The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!" Link to comment Share on other sites More sharing options...
BigDod Posted October 27, 2005 Share Posted October 27, 2005 Starting the windows dialog box directly. Genius idea (and so simple), much appreciated BigDod. Thankyou for your helpMarkHere is another attemptRun(@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 Link to comment Share on other sites More sharing options...
w0uter Posted October 27, 2005 Share Posted October 27, 2005 @BigDod thats how _RunDos does it My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
BigDod Posted October 27, 2005 Share Posted October 27, 2005 @BigDod thats how _RunDos does it 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 Link to comment Share on other sites More sharing options...
Valuater Posted October 27, 2005 Share Posted October 27, 2005 its on the top FAQ list6. 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 trickRunWait(@COMSPEC & " /c Start Default.HEP")8) Link to comment Share on other sites More sharing options...
locutus243 Posted October 28, 2005 Author Share Posted October 28, 2005 Hey guys, thanx for all the advice. Looks like wiv all the ideas you've given me that i should have no problem in the future!! Much appreciated Mark Link to comment Share on other sites More sharing options...
randallc Posted October 28, 2005 Share Posted October 28, 2005 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 ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
keilamym Posted October 28, 2005 Share Posted October 28, 2005 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) Link to comment Share on other sites More sharing options...
hankjrfan Posted October 28, 2005 Share Posted October 28, 2005 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.ThanksMarkIf 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. Link to comment Share on other sites More sharing options...
randallc Posted October 28, 2005 Share Posted October 28, 2005 Hi,@hankjrfan; I think the short names are giving people grief (see other thread)?more examplesCODE$rc = _RunDos("for /f %%s in ('dir /b *.dll') do regsvr32 /s %s")orCODE$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 spacesBest, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
LxP Posted October 31, 2005 Share Posted October 31, 2005 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) Link to comment Share on other sites More sharing options...
MHz Posted October 31, 2005 Share Posted October 31, 2005 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now