Jump to content
Sign in to follow this  

Using @ComSpec or Closing Command Prompt (revisited)

Recommended Posts


I am checking code with Microsoft BinScope 2014. It runs in a command line. You may be familiar with it if you are testing security for DLLs.

Anyway, I get a directory of .DLL and corresponding Symbol .PDB files from developers. The .dll and .pdb filenames have to match to run BinScope on them.

I create an array of DLL files, then an array of PDB files, compare the files to make sure I am only testing matching filenames, and then running them through BinScope.

I have the automated script running but because I am having problem with @ComSpec, I am using Run("CMD.exe").  It leaves a DOS box for every file. Here is some code:

For $i = $iDllCount to $aTestDllList[1]
        $iDllCount += 1
        $sCmd = "Binscope "&$sPath&$sDllFile
          ;MsgBox($MB_OK,"","File to test is "&$sDllFile&" DLLCount is "&$iDllCount)
        Send("CD C:\Program Files\Microsoft BinScope 2014\{Enter}")
        ;RunWait(@ComSpec & " /c " & "Binscope /Target "&$sDllFile,'""C:\Program Files\Microsoft BinScope 2014\""') Commented out

If I could use RunWait(@ComSpec " /c "... the DOS box would close automatically. However I can't get that to work.

I have tried

RunWait(@ComSpec&" /k "&'""Binscope.exe C:\testdll\apiREST.dll""', '""C:\Program Files\Microsoft BinScope 2014""')

RunWait(@ComSpec&" /k "&'""C:\Program Files\Microsoft BinScope 2014\Binscope.exe C:\testdll\apiREST.dll""', '""C:\Program Files\Microsoft BinScope 2014""')

In any case using the RunWait command does not work. Using Run("CMD.exe") does. I would like to close the DOS box after each file is run.

I need to either get RunWait (@ComSpec...) running OR close each DOS box after BinScope is done.

Any help is appreciated!


Share this post

Link to post
Share on other sites

C:\Users\Owner>start /?
Starts a separate window to run a specified program or command.

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/AFFINITY <hex affinity>] [/WAIT] [/B] [command/program]


Share this post

Link to post
Share on other sites

Thanks argumentum.

I realized since I was simply typing in the DOS box, all I had to do was Send ("Exit{Enter}") and the DOS Boxes will close after BinScope finished.

Problem Solved!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Fortitude
      I have made a program, that opens a folder, and then store the path ("C:\programFiles\etc") in a variable.
      Then i need to open the command panel as administrator, and write  in the stored path, and some other text.

      Can i somehow instantly copypaste the text i needed, instead of writing in the command panel with the Send commands?
      #RequireAdmin #include <MsgBoxConstants.au3> Global Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Global $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "Nem választottál ki mappát!") Exit EndIf Global $Tiff_path = $sFileSelectFolder & "\TiffChecker_2_32" FileCopy( "C:\TiffChecker_2_32.exe" , $sFileSelectFolder) $CMD = $Tiff_path & " " & $sFileSelectFolder & " /s/d" Run("C:\WINDOWS\system32\cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send($CMD) Sleep(1000) Send("{ENTER}") sleep(1000) MsgBox(0,"Press OK", "Press OK to continue") FileCopy("C:\Tiffchecker.txt", $sFileSelectFolder) Also, how do i close the command panel, when the program is finished? (usually its under 1 second, so after the send i just put a Sleep function there)
    • By Tippex
      How can I detect when a Command Prompt window has returned to idle with prompt for the next command please?
      For example, after a large paste:
                              ControlClick("[CLASS:ConsoleWindowClass]", "", "", "right")
                              ControlSend("[CLASS:ConsoleWindowClass]", "", "", "p") 
      a large paste may be something like copying some large files which may go on for some time after the paste command has been given.
    • By FrancescoDiMuro
      Good morning AutoIt community!
      Today, I'm here to ask you if you know how to run an .exe from cmd.exe ( Command Prompt )...
      My intention is to read a .ini file where I store an information that has to be included in the shell, and run an .exe with that information...
      I'll give you an example
      Local $aFileCartellaAuditCopy = _FileListToArray($sPercorsoAuditCopy, "*.txt") If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la lettura della lista dei file nella directory" & @CRLF & $sPercorsoAuditCopy & @CRLF & "Errore: " & @error) Return False Else Local $iPID = Run("cmd.exe" & ' /k "C:\Users\Portatile-60\Desktop\HmiCheckLogIntegrity.exe" "C:\Users\Portatile-60\Desktop\AuditTrailDosaggio0_20170327_151335_DOSAGGIO_PW_01.txt"') ; & " /k " & '"' & $sHmiCheckLogIntegrity & '"' & " " & '"' & $sPercorsoAuditCopy & "\" & $aFileCartellaAuditCopy[1] & '"', "", @SW_SHOW, $STDOUT_CHILD) Return True EndIf This code is in a function, that returns False if it can retrive at least a file from the path stored in the .ini file...
      I would like to run the Command Prompt with the .exe and with a parameter of that .exe, but it seems to not work properly.

      Could please anyone tell me why?

    • By Tumulus
      I need to create a new administrator account on a number of computers, so figured I would make a script to do it. 
      You can only add/modify admin profile from an elevated command prompt (administrator command prompt). So I tried writing that into my short script. I thought that my "RunAs" command below would do the trick, but it opens a standard cmd window through the admin profile.
      Anyone able to tell me how to get it to open the elevated cmd?
      RunAs("administrator",@ComputerName,$sAdminPassword,0,@ComSpec) Sleep (500) Send("net user /ADD " & $sUsername & " " & $sPassword) Send("{ENTER}") Send("Y") Send("{ENTER}") Send("net user " & $sUsername & " /passwordchg:no") Send("{ENTER}") Send("net localGroup administrators " & $sUsername & " /ADD") Send("{ENTER}") WinClose("C:\Windows\system32\cmd.exe")  
    • By lrstndm
      Hi all,
      I am working on a application with a GUI and command prompt in 1.
      Currently my code looks this simple >
      #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_Change2CUI=y #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 437, 192, 124) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd But when I compile this and run the compiled version there is also a command prompt shown. But I don't want this.
      Besides that, I also want it to be possible when I run my script from the command prompt, the program will give feedback in the command prompt where it was started from. With the setup above. This is possible with the ConsoleWrite command. 
      Is it possible to hide the command prompt one way or another when I start the GUI? Or do I have to change my script?
      I hope someone can help me.
  • Create New...