Jump to content

Hide window while running Runwit


Recommended Posts

Any body can help how to hide the cmd window with this syntax:

RunWait(@ComSpec & ' /c wmic printer get name,PortName,DriverName | sort >>  ' &$MyVariable)

where to insert SW_HIDE?? I tried all options 

Thank you 

Link to comment
Share on other sites

  • Moderators

The help file shows very clearly where you would put that, third parameter:

RunWait(<program>, <working dir>, <show_flag>, <opt_flag>)

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I would query wmi in your script. I used the ScriptoMatic.au3 that comes as an installed example for the following. You  just query and loop through your results.

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$sComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $sComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$oWMIService = ObjGet("winmgmts:\\" & $sComputer & "\root\CIMV2")
$colItems = $oWMIService.ExecQuery("SELECT * FROM Win32_PrinterDriver", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) Then
   For $objItem In $colItems
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "ConfigFile: " & $objItem.ConfigFile & @CRLF
      $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF
      $Output = $Output & "DataFile: " & $objItem.DataFile & @CRLF
      $Output = $Output & "DefaultDataType: " & $objItem.DefaultDataType & @CRLF
      $strDependentFiles = $objItem.DependentFiles(0)
      $Output = $Output & "DependentFiles: " & $strDependentFiles & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "DriverPath: " & $objItem.DriverPath & @CRLF
      $Output = $Output & "FilePath: " & $objItem.FilePath & @CRLF
      $Output = $Output & "HelpFile: " & $objItem.HelpFile & @CRLF
      $Output = $Output & "InfName: " & $objItem.InfName & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "MonitorName: " & $objItem.MonitorName & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "OEMUrl: " & $objItem.OEMUrl & @CRLF
      $Output = $Output & "Started: " & $objItem.Started & @CRLF
      $Output = $Output & "StartMode: " & $objItem.StartMode & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      $Output = $Output & "SupportedPlatform: " & $objItem.SupportedPlatform & @CRLF
      $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
      $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF
      $Output = $Output & "Version: " & $objItem.Version & @CRLF
      If MsgBox(1,"WMI Output",$Output) = 2 Then ExitLoop
      $Output=""
   Next
Else
   MsgBox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_PrinterDriver" )
EndIf


Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

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