MarkS Posted August 4, 2010 Share Posted August 4, 2010 I have this cmd line string: for /f 'tokens=2 usebackq skip=1' %%v in (`wmic csproduct get name`) do set modl=%%v When executed, it sets the variable of "modl" with D830 (I'm on a Dell Latitude D830). Is there an equivalent way to do it in AutoIt? I seem to have a mental block when it comes to for/f loops. Thanks Mark Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 4, 2010 Share Posted August 4, 2010 (edited) You can access the WMI COM object interface directly with AutoIt, but if you want to use the command line WMIC: #include <Constants.au3> Global $sExtCmd = "wmic csproduct get name" Global $iPID = Run($sExtCmd, @WorkingDir, @SW_MINIMIZE, $STDOUT_CHILD) Global $sStdOut = "" Do $sStdOut &= StdoutRead($iPID) Until @error Global $sName = StringStripWS(StringMid($sStdOut, StringInStr($sStdOut, @CRLF)), 1+2) MsgBox(64, "Name", "$sName = " & $sName) Edited August 4, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
MarkS Posted August 4, 2010 Author Share Posted August 4, 2010 You can access the WMI COM object interface directly with AutoIt, but if you want to use the command line WMIC: #include <Constants.au3> Global $sExtCmd = "wmic csproduct get name" Global $iPID = Run($sExtCmd, @WorkingDir, @SW_MINIMIZE, $STDOUT_CHILD) Global $sStdOut = "" Do $sStdOut &= StdoutRead($iPID) Until @error Global $sName = StringStripWS(StringMid($sStdOut, StringInStr($sStdOut, @CRLF)), 1+2) MsgBox(64, "Name", "$sName = " & $sName) Thanks for the quick reply, that really did the trick. So, how do you access wmi directly? Is it using the _WinAPI functions? Sorry, this is kinda new to me. I've been using batch files for 20 years but I'm beginning to see benefits of expanding my horizons..... Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 4, 2010 Share Posted August 4, 2010 Basically, anything you do in Scriptomatic with VBScript is pretty easy to translate into AutoIt: Global $oWMI = ObjGet("winmgmts:") Global $colCS = $oWMI.ExecQuery("Select * from Win32_ComputerSystem") Global $colBIOS = $oWMI.ExecQuery("Select * from Win32_BIOS") Global $sModel, $sSerial For $oComputer In $colCS $sModel = $oComputer.Model Next For $oComputer In $colBIOS $sSerial = $oComputer.SerialNumber Next MsgBox(64, "Results", "Model = " & $sModel & @CRLF & "SN = " & $sSerial) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now