Sign in to follow this  
Followers 0
Cap0

@comspec help

11 posts in this topic

how do you use @comspec with variables?

Share this post


Link to post
Share on other sites



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]

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Would you like to show the code of @ComSpec usage so someone can see the issue causing you grief?

:whistle:

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (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]

:whistle:

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 by MHz

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 work

I 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 by chaotech

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 :whistle:

Share this post


Link to post
Share on other sites

To avoid @ComSpec's Start command, you could also have a look at using ShellExecute().

:whistle:

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