Using @ComSpec or Closing Command Prompt (revisited)

3 posts in this topic


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!

1 person likes this

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

  • Similar Content

    • FrancescoDiMuro
      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?

    • Tumulus
      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")  
    • lrstndm
      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.
    • ur
      By ur
      When I execute any batch command then it is prompting a command window for 1 second till the command executes with the below command.
      $CMD = "net localgroup administrators domainaname\usename /add"
      RunWait(@ComSpec & " /q /c " & $CMD)
      Is there any way to exeute the command without showing the window.
    • theak
      By theak
      Trying to make a script where it will run a command to show me the model name AND serial tag info on a laptop remotely and copy it to keyboard step by step. I know how to do this via WMIC but I'm curious how to create a CMD script out of it so I can just one click. So it would look something like....
      wmic csproduct get name *copy to clipboard* "Press enter to advance" [Enter] wmic csproduct get identifyingnumber *copy to clipboard* "Finished" Any ideas?