Jump to content

@comspec help


Cap0
 Share

Recommended Posts

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

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

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
Link to comment
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

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
Link to comment
Share on other sites

  • Moderators

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

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:
Link to comment
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
 Share

  • Recently Browsing   0 members

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