Cap0 Posted February 24, 2007 Share Posted February 24, 2007 how do you use @comspec with variables? Link to comment Share on other sites More sharing options...
herewasplato Posted February 24, 2007 Share Posted February 24, 2007 how do you use @comspec with variables?I'm not sure that I understand your question, but take a look at this post: http://www.autoitscript.com/forum/index.ph...st&p=307206 it has a Run line that uses @comspec and a variable for the website......or do you mean changing the OS variable to another command interpreter? [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Cap0 Posted February 24, 2007 Author Share Posted February 24, 2007 Hi, yeh that's it, but i then realised my problem was, you cannot use full paths ? for example you have to have the file name("test.txt"), you can't have "D:\path\path\test.txt", any way to do this? Link to comment Share on other sites More sharing options...
MHz Posted February 24, 2007 Share Posted February 24, 2007 Would you like to show the code of @ComSpec usage so someone can see the issue causing you grief? Link to comment Share on other sites More sharing options...
Cap0 Posted February 24, 2007 Author Share Posted February 24, 2007 Hi, $file = InputBox("","Type the full path to the file") Run(@Comspec & " /c " & "start " & $file,"",@SW_HIDE) if i run that code, and type in "C:\path\path\file.exe"(it's in the same dir as the script), it won't work, but if i type in "file.exe"(assuming the script is in the file.exe dir), it will work Link to comment Share on other sites More sharing options...
MHz Posted February 24, 2007 Share Posted February 24, 2007 (edited) The internal Start command within @ComSpec will interpret the first parameter in double quotes as the title in XP and above. START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] [/AFFINITY <hex affinity>] [/WAIT] [/B] [command/program] [parameters] Edit: Try this without using double quotes. $file = InputBox("","Type the full path to the file") $file = FileGetShortName($file) Run(@Comspec & " /c " & "start " & $file,"",@SW_HIDE) Edited February 24, 2007 by MHz Link to comment Share on other sites More sharing options...
chaotech Posted February 24, 2007 Share Posted February 24, 2007 (edited) Hi, $file = InputBox("","Type the full path to the file") Run(@Comspec & " /c " & "start " & $file,"",@SW_HIDE) if i run that code, and type in "C:\path\path\file.exe"(it's in the same dir as the script), it won't work, but if i type in "file.exe"(assuming the script is in the file.exe dir), it will workI may be missing something here, but I think the problem you are having is that you are trying to combine the working path and the actual file into one variable passed to Run. The empty "" is a place holder for the working directory. Try prompting for the file name, and the path separately, then sticking them in the run function like so: $file = InputBox("","Type the file name") $path = InputBox("","Type the full path to the file") Run(@Comspec & " /c " & "start " & $file, $path,@SW_HIDE) - the $path variable should not contain the file name itself... Edited February 24, 2007 by chaotech Link to comment Share on other sites More sharing options...
Valuater Posted February 24, 2007 Share Posted February 24, 2007 Autoit wrappers has mixed uses for @Comspechttp://www.autoitscript.com/forum/index.ph...st&p=2239518) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 24, 2007 Moderators Share Posted February 24, 2007 Global $hWnd, $iPID $iPID = Run(@ComSpec);@ComSpec = cmd.exe ProcessWait($iPID) Do Sleep(10) $hWnd = HWnd(_WinGetCMD($iPID));A function I just wrote to get the right window for the right cmd.exe PID Until $hWnd If WinActive($hWnd) = 0 Then WinActivate($hWnd) Send('color 9E{ENTER}');Change the background blue and the text yellow Sleep(2000) Send('title Our Custom Title{ENTER}');Make a custom title Sleep(2000) Send('{F7}');List what we have done so far ;There are many more options to cmd.exe ;Google around and find what it is exactly you would like to do with it. Func _WinGetCMD($nPID) $OPTWTMM = Opt('WinTitleMatchMode', 4) Local $aWL = WinList('classname=ConsoleWindowClass') Opt('WinTitleMatchMode', $OPTWTMM) For $iCC = 1 To UBound($aWL) - 1 If WinGetProcess($aWL[$iCC][1]) = $nPID And _ BitAND(WinGetState($aWL[$iCC][1]), 2) Then Return $aWL[$iCC][1] EndIf Next Return SetError(1, 0, 0) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Cap0 Posted February 24, 2007 Author Share Posted February 24, 2007 The internal Start command within @ComSpec will interpret the first parameter in double quotes as the title in XP and above. START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] [/AFFINITY <hex affinity>] [/WAIT] [/B] [command/program] [parameters] Edit: Try this without using double quotes. $file = InputBox("","Type the full path to the file") $file = FileGetShortName($file) Run(@Comspec & " /c " & "start " & $file,"",@SW_HIDE) oÝ÷ Ûú®¢×¢¹,¥êßyËeË}ө䲫¨µéÚWow...amazing Link to comment Share on other sites More sharing options...
MHz Posted February 25, 2007 Share Posted February 25, 2007 To avoid @ComSpec's Start command, you could also have a look at using ShellExecute(). 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