Jump to content

Autoit Switches / CMD Location


Recommended Posts

Hi All,

I'm working on a idea to make program switch based. (No GUI and using consolewrite to display outputs)

I have a windows shortcut which opens cmd and shows display custom text instead of full path.

"C:\Windows\System32\cmd.exe /k "prompt Module$g" and Starts in "C:\MyProgram\".

My big program is split into multiple sub .exes and can be used like this

AD Ian Update (Runs AD.exe with switch ian and update)

Cisco James Delete (runs cisco.exe with switch James and delete)

I like how this works but the problem it means updating lots of exes. I would rather just one but when i do this you have to do this.

MyProgram.exe AD ian Update

MyProgram.exe Cisco James Update

To get the most out of my tool, you have to send lots of commands and having to type "MyProgram.exe" lots of times would be annoying.

Is there any way i can start command prompt like "C:\MyProgram\MyProgram.exe" so when i type into cmd it only sends the switches or is there a cool way to do this with autoit? 

Ian

 

 

 

 

Link to comment
Share on other sites

Cannot really understand what you mean here... 

How about just put your programs with the path into an array, and just run from that array? Option-1: Run from Windows directly Option-2: Run through cmd

;=== Option-1 ===
;your programs with the path into an array
Local $aMyPrograms[3] ;assume there are three applications
$aMyPrograms[0] = "MyProgram1.exe" ;assuming that it's in the same directory with your script
$aMyPrograms[1] = "C:\MyPath\Another Path\MyProgram2.exe"
;$aMyPrograms[2] = ...

For $i = 0 To UBound($aMyPrograms) - 1
    Run($aMyPrograms[$i])
Next


;=== Option-2 ===
;your programs with the path into an array
Local $aMyPrograms[3] ;assume there are three applications
$aMyPrograms[0] = "MyProgram1.exe" ;assuming that it's in the same directory with your script
$aMyPrograms[1] = "C:\MyPath\Another Path\MyProgram2.exe"
;$aMyPrograms[2] = ...

Run("cmd")
WinWait("[CLASS:ConsoleWindowClass]", "", 10)

$hWnd = WinGetHandle("Administrator: C:\Windows\system32\cmd.exe") ;check for your cmd
If @error Then
    MsgBox(0, "", "Cannot find that handle for cmd.")
    Exit
EndIf

For $i = 0 To UBound($aMyPrograms) - 1
    ControlSend($hWnd, "", "", """" & $aMyPrograms[$i] & """" & @CRLF)
Next

 

TY.

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...