Casey Posted September 1, 2010 Share Posted September 1, 2010 Hello,I have two things that I can't seem to figure out or they may not be possible. My questions probably can be answered without supporting code but I am including the code that I have done so far and these notes. This isn't much of anything but it has made my life a lot easier.Notes:1. regview.exe attachment is removed by antivirus the executable can be obtained from one of the Windows Resource Kits.2. Trace32.exe can be obtained from the SMS 2003 Toolkit 2.3. Streams.exe is from Winternals.4. WMIC.ini example is attached as WMIC.txt; You will need to rename it. Please look for FileInstall to see where I have been storing files for compilation.5. The WMIC.ini, regview.exe, streams.exe and Trace32.exe will be embedded in the compiled EXE6. Those embedded files will unpack when the EXE is executed to the directory that the EXE is executed from.7. The WMIC.ini will not be overwritten the next time that you launch the tool. This means that you can add to it as you please.8. When adding to WMIC.ini treat your entry as if you are running the WMIC command against the local box. The tool provides you the ability to target remote systems and will adjust the syntax of the command accordingly for you. 9. If you choose one of the checkboxes look for a WMIC directory @scriptdir. It will contain the output. Otherwise the output will be displayed in the command window.10. All if not most of the features of the tool will work from XP on up to Server 2008.11. The POL section will dump the security POL files into a log file that can be easily viewed with Trace32.exe. I use this to see what a Security Template has injected into the system.12. The obtain file version info returns the scriptable values that AutoIt can use for whatever file you select.13. The WMI calls for BIOS info have will return a value with < and >. This is to show you that there are blank spaces returned that you will need to account for when scripting. My appologies:1. I am still learning so I may have made more than a few bad coding choices.2. I borrowed from many sources in figuring out how to do things. I it looks like your work I offer you my thanks but it has been such a blur lately I neglected to document the sources.What I haven't figured out how to do is:1. Set a background color within the drop down in Line 70 (GUICtrlCreateCombo). I can only get the box to show color. It would be nice if I could alternate colors on lines but I don't see how to accomplish it.2. Line 369 starts my WMIC section. I have been trying to figure out a way that I can take a list of computers and call the selected WMIC command against each. The problem that I can't get around is the time that each takes to execute. How do I monitor the CMD window and watch for it to return to the prompt. I know that I could generate a .CMD file based on the command selection and the list of computer names and then execute it but I am curious if it can be done internally.expandcollapse popup#include <GuiConstants.au3> #include <File.au3> #include <Excel.au3> #include <GuiComboBox.au3> #include <GuiTab.au3> #include <WindowsConstants.au3> #RequireAdmin Global $OS, $FileVersion_1a, $FFileVersion_1a, $CPU_2, $Ping_1d AutoItSetOption("GUICloseOnESC", 1) If Not FileExists(@ScriptDir & "\00_InfoHarvest.log") Then _FileCreate(@ScriptDir & "\00_InfoHarvest.log") EndIf $InstallLog = @ScriptDir & "\00_InfoHarvest.log" $OS = @OSVersion $CMD_Format = "" ;################################################################################################################################## FileInstall("C:\Temp\Casey\WMIC.ini", @ScriptDir & "\WMIC.ini") ;################################################################################################################################## $gui = GUICreate("Output to file in same directory as this application", 700, 350) GUISetStyle(0x00CF0000) ;GuiSetStyle (0x00CF0000) ;################################################################################################################################## $tab = GUICtrlCreateTab(5, 0, 1120, 900, 0x0100) $tab0 = GUICtrlCreateTabItem("Info Harvest") ;################################################################################################################################## GUICtrlCreateGroup("Gather Scripting Information ", 10, 30, 490, 110) $Model_1 = GUICtrlCreateButton("WMI Model", 20, 50, 90, 30, 0x0100) GUICtrlSetResizing($Model_1, 1) GUICtrlSetTip(-1, "< and > are there to show you" & @CRLF & "if the query returns blank spaces " & @CRLF & "you need to account for") $SMBIOSBIOSVersion_1 = GUICtrlCreateButton("WMI SMBIOSBIOSVersion", 120, 50, 190, 30, 0x0100) GUICtrlSetResizing($SMBIOSBIOSVersion_1, 1) GUICtrlSetTip(-1, "< and > are there to show you" & @CRLF & "if the query returns blank spaces " & @CRLF & "you need to account for") $FileVersion_1 = GUICtrlCreateButton("Obtain File Version Info", 330, 50, 150, 30, 0x0100) ; Property naming "FileVersion" GUICtrlSetResizing($FileVersion_1, 1) GUICtrlSetTip(-1, "Not all files have version info." & @CRLF & "If this is the case look at files sizes") $FileVersion_2 = GUICtrlCreateButton("View Info", 160, 100, 80, 30, 0x0100) ; Property naming "Fileversion" note the lower v GUICtrlSetResizing($FileVersion_2, 1) ;################################################################################################################################## $tab1 = GUICtrlCreateTabItem("WMIC Queries") ;################################################################################################################################## GUICtrlCreateGroup("", 10, 30, 680, 170) GUICtrlCreateLabel("Remote CPU Name =", 20, 51, 120, 20) ;GUICtrlSetState(-1, $GUI_HIDE) ;GUICtrlSetFont(-1, 11, 800, 0, "folkard") GUICtrlSetColor(-1, 0x99) $CPU = GUICtrlCreateInput("", 150, 50, 140, 20) GUICtrlSetTip(-1, "If no entry then local computer name is used.") $WMIC_CK_1 = GUICtrlCreateCheckbox("/format:hform.xsl", 20, 130, 120, 20) GUICtrlSetResizing($WMIC_CK_1, 1) $WMIC_CK_2 = GUICtrlCreateCheckbox("/format:htable.xsl", 160, 130, 120, 20) GUICtrlSetResizing($WMIC_CK_2, 1) $WMIC_CK_3 = GUICtrlCreateCheckbox("/format:csv.xsl", 300, 130, 120, 20) GUICtrlSetResizing($WMIC_CK_3, 1) $GO = GUICtrlCreateButton("GO", 450, 210, 40, 30, 0x0100) GUICtrlSetResizing($GO, 1) GUICtrlSetFont(-1, 11, 800, 0, "folkard") GUICtrlSetColor(-1, 0x99) $hCombo = GUICtrlCreateCombo("", 20, 90, 650, 296, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL)) GUICtrlSetResizing($hCombo, 1) ; Add files _GUICtrlComboBox_BeginUpdate($hCombo) $var = IniReadSection(@ScriptDir & "\WMIC.ini", "WMIC_COMMANDS") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $var[0][0] _GUICtrlComboBox_AddString($hCombo, $var[$i][1]) Next EndIf _GUICtrlComboBox_EndUpdate($hCombo) ;################################################################################################################################## $tab2 = GUICtrlCreateTabItem("POL Security Files / GPResult") ;################################################################################################################################## GUICtrlCreateGroup("Read POL Security Files", 10, 30, 220, 110) $POL = GUICtrlCreateButton("Export .POL to .LOG and View", 20, 50, 200, 30, 0x0100) GUICtrlSetResizing($POL, 1) GUICtrlCreateGroup("Convert GPResult .TXT file to Excel 2003 Format Workbook ", 10, 150, 460, 85) $GPReault_1 = GUICtrlCreateButton("Run GPRESULT and Generate TXT", 30, 180, 240, 30, 0x0100) GUICtrlSetResizing($GPReault_1, 1) $GPReault_1a = GUICtrlCreateButton("Convert TXT to XLS", 290, 180, 135, 30, 0x0100) GUICtrlSetResizing($GPReault_1a, 1) ;################################################################################################################################## $tab3 = GUICtrlCreateTabItem("Data Streams - Unblock File") ;################################################################################################################################## GUICtrlCreateGroup("Data Streams - View or Remove ", 10, 30, 220, 180) $Stream_1 = GUICtrlCreateButton("Browse for File", 20, 50, 100, 30, 0x0100) GUICtrlSetResizing($Stream_1, 1) $Stream_RB_1 = GUICtrlCreateRadio("View Streams", 20, 90, 140, 20) GUICtrlSetResizing($Stream_RB_1, 1) $Stream_RB_2 = GUICtrlCreateRadio("[ -s ] Recursive Sub Dir", 20, 120, 180, 20) GUICtrlSetResizing($Stream_RB_2, 1) $Stream_RB_3 = GUICtrlCreateRadio("[ -d ] Delete Streams on a File", 20, 150, 200, 20) GUICtrlSetResizing($Stream_RB_3, 1) $Stream_RB_4 = GUICtrlCreateRadio("[ -d ] Delete Streams on a Dir", 20, 180, 200, 20) GUICtrlSetResizing($Stream_RB_4, 1) GUICtrlCreateLabel('Winternals "stream.exe"', 240, 30, 340, 100) GUICtrlCreateLabel('Usage: streams [-s] [-d] <file or directory>', 240, 50, 340, 100) GUICtrlCreateLabel(' -s Recurse subdirectories', 240, 70, 340, 100) GUICtrlCreateLabel(' -d Delete streams', 240, 90, 340, 100) GUICtrlCreateLabel("Streams will examine the files and directories (note that directories can also have alternate data streams) you specify and inform you of the name and sizes of any named streams it encounters within those files.", 240, 110, 340, 100) GUICtrlCreateLabel("Output of command will be in the STREAMS folder located from whereever you executed this tool.", 240, 180, 340, 100) ;################################################################################################################################## GUICtrlCreateTabItem("") GUISetState() ; will display an dialog box with 2 button ;################################################################################################################################## While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $WMIC_CK_1 GUICtrlSetState($WMIC_CK_2, $GUI_UNCHECKED) GUICtrlSetState($WMIC_CK_3, $GUI_UNCHECKED) $CMD_Format = " /format:hform.xsl" If FileExists("C:\Windows\System32\wbem\hform.xsl") = 0 Then FileCopy("C:\Windows\System32\wbem\en-US\hform.xsl", "C:\Windows\System32\wbem\", 0) EndIf Case $msg = $WMIC_CK_2 GUICtrlSetState($WMIC_CK_1, $GUI_UNCHECKED) GUICtrlSetState($WMIC_CK_3, $GUI_UNCHECKED) $CMD_Format = " /format:htable.xsl" If FileExists("C:\Windows\System32\wbem\htable.xsl") = 0 Then FileCopy("C:\Windows\System32\wbem\en-US\htable.xsl", "C:\Windows\System32\wbem\", 0) EndIf Case $msg = $WMIC_CK_3 GUICtrlSetState($WMIC_CK_1, $GUI_UNCHECKED) GUICtrlSetState($WMIC_CK_2, $GUI_UNCHECKED) $CMD_Format = " /format:csv.xsl" If FileExists("C:\Windows\System32\wbem\csv.xsl") = 0 Then FileCopy("C:\Windows\System32\wbem\en-US\csv.xsl", "C:\Windows\System32\wbem\", 0) EndIf Case $msg = $Model_1 $wbemFlagReturnImmediately = 0x10 ;From here..... $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $CpuModel_1 = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $CpuModel_1 = $objItem.Model ;....to here, WMI to return CPU model and supply value to variable $CpuModel_1 _FileWriteLog($InstallLog, @CRLF & @CRLF & "Computer Model<" & $CpuModel_1 & ">" & @CRLF & "____________________________________________________________________") ; Write model to log Next EndIf Case $msg = $SMBIOSBIOSVersion_1 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $SMBIOSBIOSVersion_1a = $objItem.SMBIOSBIOSVersion ;....to here, WMI to return CPU model and supply value to variable $CpuModel_1 _FileWriteLog($InstallLog, @CRLF & @CRLF & "Computer SMBIOS BIOSVersion<" & $SMBIOSBIOSVersion_1a & ">" & @CRLF & "____________________________________________________________________") ; Write model to log Next EndIf Case $msg = $FileVersion_1 $FileVersion_1a = "" _GetFile() _FileWriteLog($InstallLog, @CRLF & @CRLF & "The queried computers operating system VERSION was: " & @OSVersion & @CRLF) _FileWriteLog($InstallLog, @CRLF & @CRLF & "The queried computers operating system BUILD was: " & @OSBuild & @CRLF) _FileWriteLog($InstallLog, @CRLF & @CRLF & "The queried computers operating system SERVICEPACK was: " & @OSServicePack & @CRLF) _FileWriteLog($InstallLog, @CRLF & @CRLF & "The queried computers operating system ARCHITECTUE was: " & @OSArch & @CRLF) _FileWriteLog($InstallLog, @CRLF & @CRLF & "The queried computers operating system TYPE was: " & @OSTYPE & @CRLF & "____________________________________________________________________") $FileVersion_1b = FileGetVersion($FileVersion_1a, "Comments") _FileWriteLog($InstallLog, @CRLF & @CRLF & "File version information for " & $FileVersion_1a & @CRLF & @CRLF & " Comments:" & @CRLF & "____________________________________________________________________") $FileVersion_1c = FileGetVersion($FileVersion_1a, "InternalName") _FileWriteLog($InstallLog, "InternalName,: " & $FileVersion_1c & @CRLF & "____________________________________________________________________") $FileVersion_1d = FileGetVersion($FileVersion_1a, "ProductName") _FileWriteLog($InstallLog, "ProductName: " & $FileVersion_1d & @CRLF & "____________________________________________________________________") $FileVersion_1e = FileGetVersion($FileVersion_1a, "CompanyName") _FileWriteLog($InstallLog, "CompanyName: " & $FileVersion_1e & @CRLF & "____________________________________________________________________") $FileVersion_1f = FileGetVersion($FileVersion_1a, "LegalCopyright") _FileWriteLog($InstallLog, "LegalCopyright: " & $FileVersion_1f & @CRLF & "____________________________________________________________________") $FileVersion_1g = FileGetVersion($FileVersion_1a, "ProductVersion") _FileWriteLog($InstallLog, "ProductVersion: " & $FileVersion_1g & @CRLF & "____________________________________________________________________") $FileVersion_1h = FileGetVersion($FileVersion_1a, "FileDescription") _FileWriteLog($InstallLog, "FileDescription: " & $FileVersion_1h & @CRLF & "____________________________________________________________________") $FileVersion_1i = FileGetVersion($FileVersion_1a, "LegalTrademarks") _FileWriteLog($InstallLog, "LegalTrademarks: " & $FileVersion_1i & @CRLF & "____________________________________________________________________") $FileVersion_1j = FileGetVersion($FileVersion_1a, "PrivateBuild") _FileWriteLog($InstallLog, "PrivateBuild: " & $FileVersion_1j & @CRLF & "____________________________________________________________________") $FileVersion_1k = FileGetVersion($FileVersion_1a, "FileVersion") _FileWriteLog($InstallLog, "FileVersion: " & $FileVersion_1k & @CRLF & "____________________________________________________________________") $FileVersion_1l = FileGetVersion($FileVersion_1a, "OriginalFilename") _FileWriteLog($InstallLog, "OriginalFilename: " & $FileVersion_1l & @CRLF & "____________________________________________________________________") $FileVersion_1m = FileGetVersion($FileVersion_1a, "SpecialBuild") _FileWriteLog($InstallLog, "SpecialBuild: " & $FileVersion_1m & @CRLF & "____________________________________________________________________") $FileVersion_1n = FileGetVersion($FileVersion_1a, "CompiledScript") _FileWriteLog($InstallLog, "CompiledScript: " & $FileVersion_1n & @CRLF & "____________________________________________________________________") $FileVersion_1o = FileGetVersion($FileVersion_1a, "DefaultLangCodepage") _FileWriteLog($InstallLog, "DefaultLangCodepage: " & $FileVersion_1o & @CRLF & "____________________________________________________________________") $FileVersion_1p = FileGetVersion($FileVersion_1a) _FileWriteLog($InstallLog, "Argument without additional string name (Version): " & $FileVersion_1p & @CRLF & "____________________________________________________________________") $FileSize_1a = FileGetSize($FileVersion_1a) _FileWriteLog($InstallLog, "File Size: " & $FileSize_1a & @CRLF & "____________________________________________________________________") Case $msg = $FileVersion_2 Run("notepad.exe " & @ScriptDir & "\00_InfoHarvest.log") Case $msg = $POL If FileExists(@ScriptDir & "\POL") = 0 Then DirCreate(@ScriptDir & "\POL") ;MsgBox(0,"","DirNotExists") EndIf ;Extract and place required support files FileInstall("C:\Temp\Casey\Trace32.exe", @ScriptDir & "\POL\Trace32.exe", 0) FileInstall("C:\Temp\Casey\regview.exe", @ScriptDir & "\POL\regview.exe", 0) ;Delete any previously copied POL files If FileExists(@ScriptDir & "\POL\ntuser.pol") = 1 Then FileDelete(@ScriptDir & "\POL\ntuser.pol") EndIf If FileExists(@ScriptDir & "\POL\Registry.pol") = 1 Then FileDelete(@ScriptDir & "\POL\Registry.pol") EndIf ;Browse to get full file path for POL file to read $message = "Browse for the POL file you wish to read." $FullPathToSourcePOL = FileOpenDialog($message, @WindowsDir & "\System32\GroupPolicy\Machine", "POL File (*.pol)", 1 + 2) ;Copy desired POL to Script Directory FileCopy($FullPathToSourcePOL, @ScriptDir & "\POL", 1) ;Create arrsy from original POL file full path $POLfileArray = StringSplit($FullPathToSourcePOL, "\") ;Select last array element "number" not actuall name of file $POLfileArrayLocation = UBound($POLfileArray) - 1 ;Script processing check - shows actuall name of file in message box - code validated ;MsgBox(0,"",$POLfileArray[$POLfileArrayLocation]) ;Assign variable actuall file name $POLFile = $POLfileArray[$POLfileArrayLocation] ;Script processing check - shows actuall name of file in message box - code validated ;MsgBox(0,"",$POLFile) _POL() Case $msg = $GPReault_1 _GPReault_1b() Case $msg = $GPReault_1a _ConvertGPResultTextFile() Case $msg = $GO _Run_WMIC() Case $msg = $Stream_1 _Streams() EndSelect WEnd ;################################################################################################################################## ; File Open Function ;################################################################################################################################## Func _GetFile() $message = "Browse for the file you wish to examine." $FileVersion_1xa = FileOpenDialog($message, @WindowsDir & "\", "All (*.*)", 1 + 4) $FileVersion_1a = $FileVersion_1xa Return $FileVersion_1a EndFunc ;==>_GetFile ;FileVersion works ;4.9.0.101 DefaultLangCodepage "040904B0" , InternalName "DVTrayApp" , FileDescription "DVTrayApp" , ProductName "Tumbleweed Communications Inc. DVTrayApp" , ; CompanyName "Tumbleweed Communications Inc." , LegalCopyright "Copyright © 2005" , ProductVersion "4.9.0" , OriginalFilename "DVTrayApp.exe" ;################################################################################################################################## ; Folder Open Function ;################################################################################################################################## Func _GetFolder() $Fmessage = "Browse for the folder you wish to examine." $FFileVersion_1xa = FileSelectFolder($Fmessage, "", 6) $FFileVersion_1a = $FFileVersion_1xa Return $FFileVersion_1a EndFunc ;==>_GetFolder ;################################################################################################################################## ; Convert TXT to XLS Function ;################################################################################################################################## Func _ConvertGPResultTextFile() $message = "Select a GPResult Text File - It is in the same folder as this tool." $section = " Administrative Templates" $section_found = "" $seperator = " ------------------------" $gpo = " GPO: " $gpo_StrInStr = "" $keyname = " KeyName: " $keyname_StrInStr = "" $value = " Value: " $value_StrInStr = "" $state = " State: " $state_StrInStr = "" $a = "A" $a_r = 0 $b = "B" $c = "C" $d = "D" $x1 = 0 $savefolder = @ScriptDir Dim $aRecords $GPResultTXT = FileOpenDialog($message, "::{450D8FBA-AD25-11D0-98A8-0800361B1103}", "Text files (*.txt)", 1 + 4) If @error = 0 Then Local $oExcel = _ExcelBookNew() ;Create new book, make it visible If Not _FileReadToArray($GPResultTXT, $aRecords) Then MsgBox(4096, "Error", " Error reading log to Array error:" & @error) Exit EndIf Do $a_r = $a_r + 1 $x1 = $x1 + 1 _ExcelWriteCell($oExcel, $aRecords[$x1], $a & $a_r, 1) ;Write to the Cell If $aRecords[$x1] = $section Then $section_found = $section $a_r = $a_r + 1 EndIf Until $section_found = $section _ExcelWriteCell($oExcel, $seperator, $a & $a_r, 1) ;Write to the Cell $a_r = $a_r + 1 _ExcelWriteCell($oExcel, "GPO", $a & $a_r, 1) ;Write to the Cell _ExcelWriteCell($oExcel, "State", $b & $a_r, 1) ;Write to the Cell _ExcelWriteCell($oExcel, "Value", $c & $a_r, 1) ;Write to the Cell _ExcelWriteCell($oExcel, "Key Name", $d & $a_r, 1) ;Write to the Cell For $x = $x1 To $aRecords[0] ;Msgbox(0,'Record:' & $x, $aRecords[$x]) If $aRecords[$x] = $seperator Then $a_r = $a_r + 1 _ExcelWriteCell($oExcel, $aRecords[$x], $a & $a_r, 1) ;Write to the Cell EndIf If StringInStr($aRecords[$x], $gpo) And $section_found = $section Then $a_r = $a_r + 1 $gpo_StrInStr = StringMid($aRecords[$x], 17) _ExcelWriteCell($oExcel, $gpo_StrInStr, $a & $a_r, 1) ;Write to the Cell EndIf If StringInStr($aRecords[$x], $keyname) And $section_found = $section Then $keyname_StrInStr = StringMid($aRecords[$x], 29) _ExcelWriteCell($oExcel, $keyname_StrInStr, $d & $a_r, 1) ;Write to the Cell EndIf If StringInStr($aRecords[$x], $value) And $section_found = $section Then $value_StrInStr = StringMid($aRecords[$x], 29) _ExcelWriteCell($oExcel, $value_StrInStr, $c & $a_r, 1) ;Write to the Cell EndIf If StringInStr($aRecords[$x], $state) And $section_found = $section Then $state_StrInStr = StringMid($aRecords[$x], 29) _ExcelWriteCell($oExcel, $state_StrInStr, $b & $a_r, 1) ;Write to the Cell EndIf Next $filename = InputBox("File Name", "Please type what you would like the Excel Workbook to be named.") _ExcelBookSaveAs($oExcel, $savefolder & "\" & $filename & ".xls", "xls", 0, 1) ; Now we save it EndIf EndFunc ;==>_ConvertGPResultTextFile ;################################################################################################################################## ; Run WMIC Command Function ;################################################################################################################################## Func _Run_WMIC() Local $pud $CPU_1 = GUICtrlRead($CPU) If $CPU_1 = "" Then $CPU_2 = @ComputerName Else $CPU_2 = $CPU_1 EndIf If FileExists(@ScriptDir & "\WMIC") = 0 Then DirCreate(@ScriptDir & "\WMIC") EndIf $CMD_Output = '"' & @ScriptDir & '\WMIC\' & $CPU_2 & '-WMIC-' & @YEAR & '-' & @MON & '-' & @MDAY & '-' & @HOUR & '-' & @MIN & '-' & @SEC & '.htm' & '" ' If BitAND(GUICtrlRead($WMIC_CK_1), $GUI_CHECKED) = 0 And BitAND(GUICtrlRead($WMIC_CK_2), $GUI_CHECKED) = 0 And BitAND(GUICtrlRead($WMIC_CK_3), $GUI_CHECKED) = 0 Then $CMD_Format = "" EndIf $dud = _GUICtrlComboBox_GetCurSel($hCombo) _GUICtrlComboBox_GetLBText($hCombo, $dud, $pud) $WMIC_PATH = IniReadSection(@ScriptDir & "\WMIC.ini", "WMIC_PATH") $WMIC_PATH_1 = $WMIC_PATH[1][1] If $OS = "WIN_XP" Or $OS = "WIN_2003" Or $OS = "WIN_2000" Then Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("C:\WINDOWS\system32\cmd.exe", "") If Not WinActive("C:\WINDOWS\system32\cmd.exe", "") Then WinActivate("C:\WINDOWS\system32\cmd.exe", "") WinWaitActive("C:\WINDOWS\system32\cmd.exe", "") Send("CD\" & "{ENTER}") Send("CLS" & "{ENTER}") Send($WMIC_PATH_1, 1) Send("{ENTER}") Sleep(1000) If $CPU_2 = @ComputerName Then If $CMD_Format <> "" Then Send(" /output:" & $CMD_Output & $pud & $CMD_Format, 1) Send("{ENTER}") Else Send($pud, 1) Send("{ENTER}") EndIf Else _Ping() If $Ping_1d = "Y" Then If $CMD_Format <> "" Then Send('/node:"' & $CPU_2 & '" ' & " /output:" & $CMD_Output & $pud & $CMD_Format, 1) Send("{ENTER}") Else Send('/node:"' & $CPU_2 & '" ' & $pud, 1) Send("{ENTER}") EndIf Else Send("Exit" & "{ENTER}") Send("Exit" & "{ENTER}") MsgBox(0, "Ping Failed", "The remote system you specified was unable to be pinged.") EndIf EndIf ElseIf $OS = "WIN_VISTA" Or $OS = "WIN_7" Or $OS = "WIN_2008" Or $OS = "WIN_2008R2" Then Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("Administrator", "") If Not WinActive("Administrator", "") Then WinActivate("Administrator", "") WinWaitActive("Administrator", "") ControlSend("Administrator", "", "", "CD\" & "{ENTER}") ControlSend("Administrator", "", "", "CLS" & "{ENTER}") ControlSend("Administrator", "", "", $WMIC_PATH_1, 1) ControlSend("Administrator", "", "", "{ENTER}") Sleep(2000) If $CPU_2 = @ComputerName Then If $CMD_Format <> "" Then ControlSend("Administrator", "", "", " /output:" & $CMD_Output & $pud & $CMD_Format, 1) ControlSend("Administrator", "", "", "{ENTER}") Else ControlSend("Administrator", "", "", $pud, 1) ControlSend("Administrator", "", "", "{ENTER}") EndIf Else _Ping() If $Ping_1d = "Y" Then If $CMD_Format <> "" Then ControlSend("Administrator", "", "", '/node:"' & $CPU_2 & '" ' & " /output:" & $CMD_Output & $pud & $CMD_Format, 1) ControlSend("Administrator", "", "", "{ENTER}") Else ControlSend("Administrator", "", "", '/node:"' & $CPU_2 & '" ' & $pud, 1) ControlSend("Administrator", "", "", "{ENTER}") EndIf Else If Not WinActive("Administrator", "") Then WinActivate("Administrator", "") WinWaitActive("Administrator", "") ControlSend("Administrator", "", "", "Exit" & "{ENTER}") ControlSend("Administrator", "", "", "Exit" & "{ENTER}") MsgBox(0, "Ping Failed", "The remote system you specified was unable to be pinged.") EndIf EndIf Else EndIf EndFunc ;==>_Run_WMIC ;################################################################################################################################## ; Generate GPResult TXT Function ;################################################################################################################################## Func _GPReault_1b() Select Case $OS = "WIN_XP" Or $OS = "WIN_2003" Or $OS = "WIN_2000" $uSer = InputBox("/USER", "Please type the user you want queried. IE: contoso\john.doe.") If @error = 0 Then $Scope = InputBox("/SCOPE", "Please type the scope you want queried. IE: USER or COMPUTER.") If @error = 0 Then $verboseSwitch = InputBox("/SCOPE", "Please type the verbose switch you want queried. IE: /V or /Z.") If @error = 0 Then $filename1 = InputBox("File Name", "Please type what you would like the output to be named.") If @error = 0 Then $savefolder = @ScriptDir $savefolder_eval = StringInStr(@ScriptDir, " ") If $savefolder_eval = 0 Then $savefolder_L = '' $savefolder_R = '' Else $savefolder_L = '"' $savefolder_R = '"' EndIf Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("C:\WINDOWS\system32\cmd.exe", "") If Not WinActive("C:\WINDOWS\system32\cmd.exe", "") Then WinActivate("C:\WINDOWS\system32\cmd.exe", "") WinWaitActive("C:\WINDOWS\system32\cmd.exe", "") Send("GPResult /USER " & $uSer & " /SCOPE " & $Scope & " " & $verboseSwitch & " > " & $savefolder_L & $savefolder & "\" & $filename1 & ".txt" & $savefolder_R, 1) Send("{ENTER}") EndIf EndIf EndIf EndIf Case $OS = "WIN_VISTA" Or $OS = "WIN_7" Or $OS = "WIN_2008" Or $OS = "WIN_2008R2" $uSer = InputBox("/USER", "Please type the user you want queried. IE: contoso\john.doe.") If @error = 0 Then $Scope = InputBox("/SCOPE", "Please type the scope you want queried. IE: USER or COMPUTER.") If @error = 0 Then $verboseSwitch = InputBox("/SCOPE", "Please type the verbose switch you want queried. IE: /V or /Z.") If @error = 0 Then $filename1 = InputBox("File Name", "Please type what you would like the output to be named.") If @error = 0 Then $savefolder = @ScriptDir $savefolder_eval = StringInStr(@ScriptDir, " ") If $savefolder_eval = 0 Then $savefolder_L = '' $savefolder_R = '' Else $savefolder_L = '"' $savefolder_R = '"' EndIf Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("Administrator", "") If Not WinActive("Administrator", "") Then WinActivate("Administrator", "") WinWaitActive("Administrator", "") ControlSend("Administrator", "", "", "GPResult /USER " & $uSer & " /SCOPE " & $Scope & " " & $verboseSwitch & " > " & $savefolder_L & $savefolder & "\" & $filename1 & ".txt" & $savefolder_R, 1) ControlSend("Administrator", "", "", "{ENTER}") EndIf EndIf EndIf EndIf Case Else MsgBox(0, "OS Version", "You are not running a supported operating system") EndSelect EndFunc ;==>_GPReault_1b ;################################################################################################################################## ; XP 2000 2003 POL File Function ;################################################################################################################################## Func _POL() Select Case $OS = "WIN_XP" Or $OS = "WIN_2003" Or $OS = "WIN_2000" $POL_Output = "regpol-" & @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & "-" & @MIN & "-" & @SEC & ".log" ;Run regview command line from admin command prompt and output logfile to script directory Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("C:\WINDOWS\system32\cmd.exe", "") If Not WinActive("C:\WINDOWS\system32\cmd.exe", "") Then WinActivate("C:\WINDOWS\system32\cmd.exe", "") WinWaitActive("C:\WINDOWS\system32\cmd.exe", "") Send('"' & @ScriptDir & '\POL\regview.exe' & '" ' & '"' & @ScriptDir & "\POL\" & $POLFile & '"' & " > " & '"' & @ScriptDir & "\POL\" & $POL_Output & '"', 1) Send("{ENTER}") ;Wait for regview process to complete processing If ProcessExists("regview.exe") Then ProcessWaitClose("regview.exe") EndIf ;Open log file with trace32 @ScriptDir & "\POL" If Not WinActive("C:\WINDOWS\system32\cmd.exe", "") Then WinActivate("C:\WINDOWS\system32\cmd.exe", "") WinWaitActive("C:\WINDOWS\system32\cmd.exe", "") Send('"' & @ScriptDir & '\POL\Trace32.exe ' & '"' & ' "' & @ScriptDir & '\POL\' & $POL_Output & '"', 1) Send("{ENTER}") Send("Exit" & "{ENTER}", 0) Case $OS = "WIN_VISTA" Or $OS = "WIN_7" Or $OS = "WIN_2008" Or $OS = "WIN_2008R2" $POL_Output = "regpol-" & @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & "-" & @MIN & "-" & @SEC & ".log" ;Run regview command line from admin command prompt and output logfile to script directory Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("Administrator", "") If Not WinActive("Administrator", "") Then WinActivate("Administrator", "") WinWaitActive("Administrator", "") ControlSend("Administrator", "", "", '"' & @ScriptDir & '\POL\regview.exe' & '" ' & '"' & @ScriptDir & "\POL\" & $POLFile & '"' & " > " & '"' & @ScriptDir & "\POL\" & $POL_Output & '"', 1) ControlSend("Administrator", "", "", "{ENTER}") ;Wait for regview process to complete processing If ProcessExists("regview.exe") Then ProcessWaitClose("regview.exe") EndIf ;Open log file with trace32 If Not WinActive("Administrator", "") Then WinActivate("Administrator", "") WinWaitActive("Administrator", "") ControlSend("Administrator", "", "", '"' & @ScriptDir & '\POL\Trace32.exe ' & '"' & ' "' & @ScriptDir & '\POL\' & $POL_Output & '"', 1) ControlSend("Administrator", "", "", "{ENTER}") ControlSend("Administrator", "", "", "Exit" & "{ENTER}") EndSelect EndFunc ;==>_POL ;################################################################################################################################## ; View Datastreams Function ;################################################################################################################################## Func _Streams() If FileExists(@ScriptDir & "\STREAMS") = 0 Then DirCreate(@ScriptDir & "\STREAMS") EndIf FileInstall("C:\Temp\Casey\streams.exe", @ScriptDir & "\STREAMS\streams.exe") $Stream_RB_1a = GUICtrlRead($Stream_RB_1) $Stream_RB_2a = GUICtrlRead($Stream_RB_2) $Stream_RB_3a = GUICtrlRead($Stream_RB_3) $Stream_RB_4a = GUICtrlRead($Stream_RB_4) Select Case $Stream_RB_1a = $GUI_CHECKED _GetFile() If $FileVersion_1a = "" Then Else ;Create arrsy from original POL file full path $StreamFileArray = StringSplit($FileVersion_1a, "\") ;Select last array element "number" not actuall name of file $StreamFileArrayLocation = UBound($StreamFileArray) - 1 ;Assign variable actuall file name $StreamFile = $StreamFileArray[$StreamFileArrayLocation] Select Case $OS = "WIN_XP" Or $OS = "WIN_2003" Or $OS = "WIN_2000" Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("C:\WINDOWS\system32\cmd.exe", "") If Not WinActive("C:\WINDOWS\system32\cmd.exe", "") Then WinActivate("C:\WINDOWS\system32\cmd.exe", "") WinWaitActive("C:\WINDOWS\system32\cmd.exe", "") Send('"' & @ScriptDir & '\STREAMS\streams.exe' & '" "' & $FileVersion_1a & '" > ' & '"' & @ScriptDir & '\STREAMS\' & $StreamFile & '.txt"', 1) Send("{ENTER}") Case $OS = "WIN_VISTA" Or $OS = "WIN_7" Or $OS = "WIN_2008" Or $OS = "WIN_2008R2" Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("Administrator", "") If Not WinActive("Administrator", "") Then WinActivate("Administrator", "") WinWaitActive("Administrator", "") ControlSend("Administrator", "", "", '"' & @ScriptDir & '\STREAMS\streams.exe' & '" "' & $FileVersion_1a & '" > ' & '"' & @ScriptDir & '\STREAMS\' & $StreamFile & '.txt"', 1) ControlSend("Administrator", "", "", "{ENTER}") EndSelect EndIf Case $Stream_RB_2a = $GUI_CHECKED _GetFolder() If $FFileVersion_1a <> "" Then $FStreamFileArray = StringSplit($FFileVersion_1a, "\") ;Select last array element "number" not actuall name of file $FStreamFileArrayLocation = UBound($FStreamFileArray) - 1 ;Assign variable actuall file name $FStreamFile = $FStreamFileArray[$FStreamFileArrayLocation] Select Case $OS = "WIN_XP" Or $OS = "WIN_2003" Or $OS = "WIN_2000" Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("C:\WINDOWS\system32\cmd.exe", "") If Not WinActive("C:\WINDOWS\system32\cmd.exe", "") Then WinActivate("C:\WINDOWS\system32\cmd.exe", "") WinWaitActive("C:\WINDOWS\system32\cmd.exe", "") Send('"' & @ScriptDir & '\STREAMS\streams.exe' & '" -s "' & $FFileVersion_1a & '" > ' & '"' & @ScriptDir & '\STREAMS\' & $FStreamFile & '_s.txt"', 1) Send("{ENTER}") Case $OS = "WIN_VISTA" Or $OS = "WIN_7" Or $OS = "WIN_2008" Or $OS = "WIN_2008R2" Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("Administrator", "") If Not WinActive("Administrator", "") Then WinActivate("Administrator", "") WinWaitActive("Administrator", "") ControlSend("Administrator", "", "", '"' & @ScriptDir & '\STREAMS\streams.exe' & '" -s "' & $FFileVersion_1a & '" > ' & '"' & @ScriptDir & '\STREAMS\' & $FStreamFile & '_s.txt"', 1) ControlSend("Administrator", "", "", "{ENTER}") EndSelect EndIf Case $Stream_RB_3a = $GUI_CHECKED _GetFile() If $FileVersion_1a = "" Then Else ;Create arrsy from original POL file full path $StreamFileArray = StringSplit($FileVersion_1a, "\") ;Select last array element "number" not actuall name of file $StreamFileArrayLocation = UBound($StreamFileArray) - 1 ;Assign variable actuall file name $StreamFile = $StreamFileArray[$StreamFileArrayLocation] Select Case $OS = "WIN_XP" Or $OS = "WIN_2003" Or $OS = "WIN_2000" Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("C:\WINDOWS\system32\cmd.exe", "") If Not WinActive("C:\WINDOWS\system32\cmd.exe", "") Then WinActivate("C:\WINDOWS\system32\cmd.exe", "") WinWaitActive("C:\WINDOWS\system32\cmd.exe", "") ;MsgBox(0,"",@ScriptDir & "\POL\regview.exe " & @ScriptDir & "\POL\" & $POLFile & " > " & @ScriptDir & "\POL\" & $POL_Output) Send('"' & @ScriptDir & '\STREAMS\streams.exe' & '" -d "' & $FileVersion_1a & '" > ' & '"' & @ScriptDir & '\STREAMS\' & $StreamFile & '_d.txt"', 1) Send("{ENTER}") Case $OS = "WIN_VISTA" Or $OS = "WIN_7" Or $OS = "WIN_2008" Or $OS = "WIN_2008R2" Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("Administrator", "") If Not WinActive("Administrator", "") Then WinActivate("Administrator", "") WinWaitActive("Administrator", "") ControlSend("Administrator", "", "", '"' & @ScriptDir & '\STREAMS\streams.exe' & '" -d "' & $FileVersion_1a & '" > ' & '"' & @ScriptDir & '\STREAMS\' & $StreamFile & '_d.txt"', 1) ControlSend("Administrator", "", "", "{ENTER}") EndSelect EndIf Case $Stream_RB_4a = $GUI_CHECKED _GetFolder() If $FFileVersion_1a <> "" Then $FStreamFileArray = StringSplit($FFileVersion_1a, "\") ;Select last array element "number" not actuall name of file $FStreamFileArrayLocation = UBound($FStreamFileArray) - 1 ;Assign variable actuall file name $FStreamFile = $FStreamFileArray[$FStreamFileArrayLocation] Select Case $OS = "WIN_XP" Or $OS = "WIN_2003" Or $OS = "WIN_2000" Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("C:\WINDOWS\system32\cmd.exe", "") If Not WinActive("C:\WINDOWS\system32\cmd.exe", "") Then WinActivate("C:\WINDOWS\system32\cmd.exe", "") WinWaitActive("C:\WINDOWS\system32\cmd.exe", "") Send('"' & @ScriptDir & '\STREAMS\streams.exe' & '" -d "' & $FFileVersion_1a & '" > ' & '"' & @ScriptDir & '\STREAMS\' & $FStreamFile & '_d.txt"', 1) Send("{ENTER}") Case $OS = "WIN_VISTA" Or $OS = "WIN_7" Or $OS = "WIN_2008" Or $OS = "WIN_2008R2" Run(@ComSpec & " /c " & 'cmd.exe', "C:\Windows\System32") Opt("WinTitleMatchMode", 4) Opt("WinDetectHiddenText", 1) WinWait("Administrator", "") If Not WinActive("Administrator", "") Then WinActivate("Administrator", "") WinWaitActive("Administrator", "") ControlSend("Administrator", "", "", '"' & @ScriptDir & '\STREAMS\streams.exe' & '" -d "' & $FFileVersion_1a & '" > ' & '"' & @ScriptDir & '\STREAMS\' & $FStreamFile & '_d.txt"', 1) ControlSend("Administrator", "", "", "{ENTER}") EndSelect EndIf Case Else EndSelect EndFunc ;==>_Streams ;################################################################################################################################## ; Ping ;################################################################################################################################## _Ping() Func _Ping() Dim $Ping_1a = 0 If @error == 0 Then For $Ping_1b = 1 To 2 $Ping_1c = Ping($CPU_2, 250) If @error = 0 Then $Ping_1d = "Y" ElseIf @error = 1 Then $Ping_1d = "N" ElseIf @error = 2 Then $Ping_1d = "N" ElseIf @error = 3 Then $Ping_1d = "N" Else $Ping_1d = "N" EndIf ;$Ping_1a = $Ping_1c + $Ping_1a Next ;MsgBox(4096, "Results", "Average roundtrip time: " & $Ping_1a / 5 & " ms") ElseIf @error == 1 Then $Ping_1d = "N" EndIf EndFunc ;==>_PingAny insight would be greatly appreciated.Thanks,CaseyWMIC.txt Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 2, 2010 Moderators Share Posted September 2, 2010 Casey, For a coloured combo, take a look here. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Casey Posted September 2, 2010 Author Share Posted September 2, 2010 Casey, For a coloured combo, take a look here. M23 Melba.. Thank youfor pointing me in that direction. I admit that it is going to take me a bit to comprehend but it looks like I can adapt the concept to exactly what I want. Any idea on the second question? Thanks again, Casey 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