Jump to content

runwait with output


 Share

Recommended Posts

RunWait(@ComSpec & " /c " & 'wmic bios get /format:value|find "SMBIOSBIOSVersion">' & @ScriptDir & "\file.txt", "", @SW_HIDE)

I am trying to refine my code here so that I don't have extra files created by the program. How do I get this to put the output into an array or usable location in the program, without creating a file in the process?

RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!!

Link to comment
Share on other sites

Instead of using wmic you can do it directly with AutoIt and then there's no need for the console output or trying to get it to read it correctly.

; Generated by AutoIt Scriptomatic

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

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:" & $strComputer & "rootCIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output &= "SMBIOSBIOSVersion: " & $objItem.SMBIOSBIOSVersion & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_BIOS" )
Endif

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

First, that code won't work if @ScriptDir contains spaces because your quotes are wrong.

Second, you need to use the Run command and set the "opt_flag" to 6. $STDOUT_CHILD + $STDERR_CHILD = 6

Third, you use StdoutRead to get the output from the console.

Here's the proper code. $sBuf is the variable that will contain the output. The ConsoleWrite is there just to show that the code is working.

Global $iPid = Run(@ComSpec & ' /c wmic bios get /format:value|find "SMBIOSBIOSVersion"', @TempDir, @SW_HIDE, 6), $sBuf
While Not @error
    $sBuf &= StdoutRead($iPid)
WEnd
ConsoleWrite($sBuf & @CRLF)

One small problem here. For some reason this code creates an empty batch file in the working directory. I've set the working directory to the temp directory so the batch file won't be seen. You could also use FileDelete to remove the batch file.

I must apologize for the spaces. I was very frustrated at the time.

Now what I want, I can see it in the Console. Great, but I still can't do anything with it.

$01 = StringTrimLeft(StringStripWS(FileReadLine(String($sBuf),1),8),18)
MsgBox(0,"","BIOS_"&$01,10)

I have compiled it to be sure that I was doing it correctly.

RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!!

Link to comment
Share on other sites

Look for a script called Scriptomatic on here, it's the AutoIt version of the Microsoft Scriptomatic. It will expose practically everything that WMI can access in autoit and output a script for you to adapt to your needs. If you can do it with wmic, you can probably do it with AutoIt natively.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

If you download the version in you should be able to run it without any error messages popping up. The original script is pretty old and the language has changed in the 6 years since it was first posted.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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