Jump to content
JibsMan

Using @ComSpec or Closing Command Prompt (revisited)

Recommended Posts

JibsMan

Hello,

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)
        Run("CMD.exe","")
        Sleep(500)
        Send("CD C:\Program Files\Microsoft BinScope 2014\{Enter}")
        Sleep(500)
        Send($sCmd&"{Enter}")
        ;RunWait(@ComSpec & " /c " & "Binscope /Target "&$sDllFile,'""C:\Program Files\Microsoft BinScope 2014\""') Commented out
    Next


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!

JibsMan

Share this post


Link to post
Share on other sites
argumentum

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

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/AFFINITY <hex affinity>] [/WAIT] [/B] [command/program]
      [parameters]

 

Share this post


Link to post
Share on other sites
JibsMan

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!

  • Like 1

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

    • Tippex
      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.
       
       
       
    • 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...
      Else
      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?

      Thanks  
    • 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.
      Regards,
      lrstndm
    • 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.
×