Guest Guest_oYx Posted June 16, 2004 Share Posted June 16, 2004 here is a simplified example of how it doesn't run:Run (@ComSpec & " /c C:\(test).txt")here is the actual line from my script, which allows me to run any file that windows recognises:Run (@ComSpec & " /c " & """" & $targetpath & $file & """", "", @SW_HIDE)any idea how to resolve that? Link to comment Share on other sites More sharing options...
Guest oYx Posted June 16, 2004 Share Posted June 16, 2004 i realised brackets are not the only problem. the ampersand (&) in filenames affects the script too. Link to comment Share on other sites More sharing options...
pekster Posted June 16, 2004 Share Posted June 16, 2004 (edited) here is the actual line from my script, which allows me to run any file that windows recognisesNot quite. You can't run anything except Exe and Com files without using the application required to run them. For example, if you had the full path of a text file in $file, you could open them with notepad by using: Run(@ComSpec & " /c notepad.exe " & '"' & $file & '"', "", @SW_HIDE) If your filename contains the "&" character, it shouldn't matter. Typo corrected Edited June 16, 2004 by pekster [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
Valik Posted June 16, 2004 Share Posted June 16, 2004 This seems to work: Run(@ComSpec & ' /k ""C:\(test).txt""') as does this (odd looking) bit: Run(@ComSpec & ' /k C:\"(test).txt"') Perhaps double quotes will also fix the ampersand issue, too. The last paragraph of a cmd /? says this: The special characters that require quotes are: <space> &()[]{}^=;!'+,`~Possible reason this occurs: The double quotes are necessary because of the way the command line works. Let's break down what each program is getting: Using this string: @ComSpec & ' /k "C:\(test).txt"' Console (@ComSpec) gets this string passed to it: /k C:\(test).txtNotice the lack of quotes around the file name. That's because they were stripped when passed. Now, when the command interpreter tries to run it, it errors because file names with () need to be in quotes. Now take the string: @ComSpec & ' /k ""C:\(test).txt""' The command interpreter gets: /k "C:\(test).txt"So now when it tries to run the file name to open it, it has a properly quoted file name to use. This may seem very confusing, but it is normal. I can reproduce all the success and failure cases with or without AutoIt. Link to comment Share on other sites More sharing options...
Guest oYx Posted June 16, 2004 Share Posted June 16, 2004 Not quite. You can't run anything except Exe and Com files without using the application required to run them.not true. i have used it to run any file that i can run by double-clicking on in windows explorer. for example: mp3, avi, mid, jpg, wav, etc.as long as it's already associated with the program that runs the file in windows, that line will run them. Link to comment Share on other sites More sharing options...
Guest oYx Posted June 16, 2004 Share Posted June 16, 2004 Valik, i'm going to accuse you of being nice now. thanks for your time in replying. i'll try your method out now. Link to comment Share on other sites More sharing options...
Guest oYx Posted June 16, 2004 Share Posted June 16, 2004 (edited) Run (@ComSpec & " /c " & '""' & $file & '""', "", @SW_HIDE) that runs every file now - even with special characters in the filename. thanks for the push in the right direction! Edited June 16, 2004 by oYx 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