MediaWiki API result

This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use.

Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json.

See the complete documentation, or the API help for more information.

{
    "batchcomplete": "",
    "continue": {
        "gapcontinue": "Sandbox",
        "continue": "gapcontinue||"
    },
    "warnings": {
        "main": {
            "*": "Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes."
        },
        "revisions": {
            "*": "Because \"rvslots\" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used."
        }
    },
    "query": {
        "pages": {
            "2800": {
                "pageid": 2800,
                "ns": 0,
                "title": "Recursion",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "[[Category:Tutorials]]\nRecursion is a topic which many find difficult to grasp and even more difficult to realise.  However, as I hope this tutorial will show, it is not that daunting and can prove very useful.  However, you do need to take great care when using recursion, including tidying up after yourself, as otherwise you can crash your system very quickly.\n\n=What is recursion?=\nLet us start by explaining what is meant by recursion.  Basically it means a function calling itself while the original function is still running.  You might wonder why you would ever want to do this - perhaps the simplest example is searching through a folder structure where you need to look in each of the subfolders you find at each level.  Another example would be my ''GUIFrames'' UDF where I use recursion to resize the frames inside a resized GUI, even if the frames are inside other frames - each resized element uses the same function to resize the elements within it.  Without recursion this would be almost impossible to do.\n\n=Why is recursion difficult to use?=\nSo now we know what recursion is, why is it tricky to use?  The following is a very simplistic explanation, but it will suffice to illustrate the problem.  Like any other application, AutoIt maintains an area of memory known as the ''stack'' where it stores temporary data.  When you call a function, AutoIt puts a fair amout of data onto the ''stack'' so that it can reload it when the function returns and so knows where it was, what it was doing and what the various variable values were.  If you call other functions from within the running function, the amount of data in the ''stack'' increases each time and if you do it enough times you can get a \"''stack overflow''\" error which usually spells disaster!  Of course, most scripts do not nest functions to any great depth and the ''stack'' is comfortably large enough to cope as the data is removed once the function returns.  But recursion, where a function keeps calling itself, can lead to a very rapid increase in the amount of ''stack'' space required and so a rapid crash.  AutoIt actually prevents the crash by limiting the recursion level - it will not allow you to store too many datasets (i.e. call too many functions without ever getting back to the main idle loop) on the ''stack''.  It is extremely unlikely that you would ever get anywhere close to this limit unless you get into a recursive loop with a function calling itself.\n\n=Some simple examples - bad and good!=\nSo what does a recursive loop look like?  Here is a very simple example which on first glance looks as if it will just print an ever-increasing value in the console.  But try running it - it will not work as you might think, but it will not harm your machine:\n<syntaxhighlight lang=\"autoit\">\n _AddOne(0)\n \n Func _AddOne($i)\n \n     ConsoleWrite(\"In: \" & $i & @CRLF)\n \n     $i += 1\n \n     _AddOne($i)\n \n     ConsoleWrite(\"Out: \" & $i & @CRLF)\n \n EndFunc\n</syntaxhighlight>\nI get to 3898 and then see:\n\n''M:\\Program\\Au3 Scripts\\Recursion Demo.au3 (13) : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.:''\n\nAs you see, you get the \"''In''\" values printed, but as you immediately call the function again you never get to see the \"''Out''\" values as you never actually reach that point in the function - you are in an infinite recursive loop and only AutoIt's built-in limit prevents a crash as the ''stack'' approaches overflow.\n\nBut adding a single limit line to prevent the infinite loop will show how recursion can work without this problem:\n<syntaxhighlight lang=\"autoit\">\n _AddOne(0)\n \n Func _AddOne($i)\n \n     ConsoleWrite(\"In: \" & $i & @CRLF)\n \n     $i += 1\n \n     If $i = 100 Then Return ; This is where we break the infinite recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<<\n \n     _AddOne($i)\n \n     ConsoleWrite(\"Out: \" & $i & @CRLF)\n \n EndFunc\n</syntaxhighlight>\nHere you can see that the \"''In''\" values are printed as before until the limit is reached and the final function returns.  This triggers all the other functions that had been called to continue to run and you get the \"''Out''\" values printed.  Note that they are in the reverse order as AutoIt pulls the data back from the ''stack'' and resets each function to the state it was in before the recursive call.\n\n=A practical use of recursion=\nI hope the above has made it clear what recursion is and why you must make sure that you do not enter an infinite recursive loop.  Let us now look at a practical application of recursion - searching a folder tree.\n\nThe problem is simple - we need to search an initial folder - and any subfolders that we find within that folder - and any subfolders within those subfolders - and any subfolder within those subfolders......  You can see why recursion might be useful here!  This is a very simple script to list the files in the \"''Extras''\" folder of your AutoIt install:\n<syntaxhighlight lang=\"autoit\">\n ListFiles_Recursive(@ProgramFilesDir & \"\\AutoIt3\\Extras\")\n \n Func ListFiles_Recursive($sSourceFolder)\n \n     Local $sFile\n \n     ; Force a trailing \\\n     If StringRight($sSourceFolder, 1) <> \"\\\" Then $sSourceFolder &= \"\\\"\n \n     ; Start the search\n     Local $hSearch = FileFindFirstFile($sSourceFolder & \"*.*\")\n     ; If no files found then return\n     If $hSearch = -1 Then Return ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<<\n \n         ; Now run through the contents of the folder\n         While 1\n             ; Get next match\n             $sFile = FileFindNextFile($hSearch)\n             ; If no more files then close search handle and return\n             If @error Then ExitLoop  ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<<\n \n             ; Check if a folder\n             If @extended Then\n                 ; If so then call the function recursively\n                 ListFiles_Recursive($sSourceFolder & $sFile)\n             Else\n                 ; If a file than write path and name\n                 ConsoleWrite(\"Found: \" & $sSourceFolder & $sFile & @CRLF)\n             EndIf\n         WEnd\n \n         ; Close search handle\n         FileClose($hSearch)\n \n EndFunc   ;==>ListFiles_Recursive\n</syntaxhighlight>\nThe 2 <<<<<<<<<<< lines are the limiters to prevent infinite recursion.  The first returns when the ''FileFindFirstFile'' does not find any files in a folder, the second when ''FileFindNextFile'' finds no more files in a folder.  Take careful note of the difference in the action the 2 limiters take - the first returns instantly, the second exits the loop to make sure that the ''$hSearch'' handle is closed before returning.  This is a good example of the \"''tidying up''\" I mentioned right at the beginning - there are only a limited number of handles available and leaving one open each time you call a recursive function is a good recipe for a catastophe later on.\n\nI hope this short introduction to recursion has clarified what it is and why you need to take such care when using it.  However, I would advise you '''not''' to use recursion unless there is absolutely no alternative.  Unless you take extreme care, it is simply too easy to mess up the limiters and end up in an infinite recursive loop.\n\n=A way of avoiding of recursion=\nSo what can you do when recursion seems the obvious and best solution?  One possibility is to look at iteration, where you call a function several times but return from it each time and then restart it with another set of parameters.  Here is a very similar file listing script to the example above using an iterative technique.  Each time a subfolder is found its path is added to an array and the internal loop continues until all them have been searched:\n<syntaxhighlight lang=\"autoit\">\n ListFiles_Iterative(@ProgramFilesDir & \"\\AutoIt3\\Extras\")\n \n Func ListFiles_Iterative($sSourceFolder)\n \n     Local $sFile\n \n     ; Force a trailing \\\n     If StringRight($sSourceFolder, 1) <> \"\\\" Then $sSourceFolder &= \"\\\"\n     ; Create an array to hold the folders to be searched\n     Local $aFolderList[10] = [1, $sSourceFolder]\n \n     ; Search within listed folders until all have been searched\n     While $aFolderList[0] > 0\n \t\n         ; Get path of folder to search\n         Local $sSearchPath = $aFolderList[$aFolderList[0]]\n         ; Remove folder from list\n         $aFolderList[0] -= 1\n \n         ; Start the search\n         Local $hSearch = FileFindFirstFile($sSearchPath & \"*.*\")\n         ; If failure then return\n         If $hSearch = -1 Then Return\n \t\n         ; Now run through the contents of the folder\n         While 1\n             ; Get next match\n             $sFile = FileFindNextFile($hSearch)\n             ; If no more files then close search handle and return\n             If @error Then ExitLoop\n             ; If a folder then add to array to be searched\n             If @extended Then\n \t\n                 ; #######################################\n \t\n                 ; Increase folder count\n                 $aFolderList[0] += 1\n                 ; Double array size if too small (fewer ReDim needed)\n                 If UBound($aFolderList) <= $aFolderList[0] Then ReDim $aFolderList[UBound($aFolderList) * 2]\n                 ; Add folder\n                 $aFolderList[$aFolderList[0]] = $sSearchPath & $sFile & \"\\\"\n \t\t\n                 ; #######################################\n \t\n             Else\n                 ; If a file than write path and name\n                 ConsoleWrite(\"Found: \" & $sSearchPath & $sFile & @CRLF)\n             EndIf\n         WEnd\n \n         ; Close search handle\n         FileClose($hSearch)\n \n     WEnd\n \n EndFunc   ;==>ListFiles_Iterative\n</syntaxhighlight>\nAs you can see, you get the same files listed - and no recursion used at all!\n\n=A little added extra=\nIf you have been good enough to read this far, you might like to look carefully at the code between the ######## lines in the example above where the subfolders found are added to the ''$aFolderList'' array.  The code uses a clever trick to speed up the script.  ''ReDim'' is among the slowest of the AutoIt functions, so you want to limit its use as much as possible.  If we were to increase the array size by just the one element each time we added a folder, we would slow down the function enormously - it makes little difference here but imagine if you were scanning an entire drive.  Instead of adding a single additional element we double the array in size if it is already full to make sure we get plenty of extra space.  You will need to have a count variable available to do this - so why not in the [0] element as is the case for many AutoIt arrays?  Just remember that if you want to use the array subsequently (unlike here where it is discarded) you will need one final ''ReDim'' to get rid of any unused elements left over after the last increase in size."
                    }
                ]
            },
            "2028": {
                "pageid": 2028,
                "ns": 0,
                "title": "RemoteWmiInfo",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "[[Category:Samples]]\n<b>Script:</b> remoteWMIInfo\n\n<b>Author:</b> Jon Dunham\n\n<b>Description:</b> Mostly-functioning example script for how to retrieve WMI information, as well as working with GUI controls. I currently use it a lot in my job, and works quite well at this point. It's commented sparingly thus far, but I'll try and and comment more of it for educational purposes. Please don't hesitate to contact me if you find problems with it or have ideas on improving its efficiency.\n\n<b>Notes:</b> The Remote and Logoff buttons are disabled by default, as they're dependent on whether you have access to an internal LANDesk management suite URL (which is what I use specifically, it could also easily be changed to use WinVNC and the like), as well as the psShutdown tool. Also, bear this in mind:\n\n\"my code is a dog's code\" - <i>R. Beef Kazenzakis</i>\n\n----\n<source lang=autoit>\n; UDF\n#include <date.au3>\n#include <ie.au3>\n#include <array.au3>\n#include <misc.au3>\n#include <guiStatusBar.au3>\n\n; Standard\n#include <EditConstants.au3>\n#include <GUIConstantsEx.au3>\n#include <StaticConstants.au3>\n#include <WindowsConstants.au3>\n#include <ButtonConstants.au3>\n#include <Constants.au3>\n\n; -( remoteWmiInfo )--------------------\n;\n; \u00a9 Jon Dunham 2009\n;\n; displays WMI and AD info including;\n; \t0: Computer model\n;\t1: Serial Number & Asset (if found)\n;\t2: BIOS Version\n;\t3: total RAM\n;\t4: Operating system & service pack\n;\t5: MAC Address\n;   6; private IP\n;\t7: current domain/user, including display name and SID (in a tooltip)\n;\t8: DefaultUserName, including display name and SID (in a tooltip)\n;\t9: time to connect in ms & ping\n;  10: Bottom-level OU\n;  11; IP address\n;  12; wireless info from wirelessInfo.au3\n;  13; active monitor model\n;  14; active monitor serial (to some extent)\n;  BLAH BLAH I'M NOT UPDATING THIS ANY MORE\n;\n; also uses psShutdown and LANDesk\n;  for remoting convenience\n;\n; ======================================\n\nDim $compName, $go, $done\nGlobal Const $version = \"0.4.10\"\nGlobal $debug = 0\nGlobal $pathSave = @MyDocumentsDir & \"\\remoteWmiInfo Queries\\\"\n\nAutoItSetOption(\"TrayAutoPause\", 0)\nAutoItSetOption(\"GUICloseOnESC\", 1)\n\n;HotKeySet( \"{ENTER}\", \"hotkey_enter\" )\n;HotKeySet( \"{F1}\", \"aboutDiag\" )\n\n; make sure icons exist\nDirCreate(\"Icons\")\nIf Not FileExists(\"Icons\\Dialog-Apply.ico\") Then _\n\t\tFileInstall(\"Icons\\Dialog-Apply.ico\", \"Icons\\Dialog-Apply.ico\")\nIf Not FileExists(\"Icons\\Gnome-Document-Save.ico\") Then _\n\t\tFileInstall(\"Icons\\Gnome-Document-Save.ico\", \"Icons\\Gnome-Document-Save.ico\")\nIf Not FileExists(\"Icons\\Gnome-Preferences-Desktop-Remote-Desktop.ico\") Then _\n\t\tFileInstall(\"Icons\\Gnome-Preferences-Desktop-Remote-Desktop.ico\", \"Icons\\Gnome-Preferences-Desktop-Remote-Desktop.ico\")\nIf Not FileExists(\"Icons\\Gnome-Application-Exit.ico\") Then _\n\t\tFileInstall(\"Icons\\Gnome-Application-Exit.ico\", \"Icons\\Gnome-Application-Exit.ico\")\n\n\n#Region ### START Koda GUI section ### Form=\n$frmInfo = GUICreate(\"remoteWmiInfo \" & $version, 337, 377, @DesktopWidth / 2, @DesktopHeight * 0.3)\n$winSize = WinGetClientSize($frmInfo)\nGUISetBkColor(0xEEEEEE)\nGUISetIcon(\"Icons\\Gnome-System-Search.ico\")\n\n;\tTop Controls\n$editComp = GUICtrlCreateInput(@ComputerName, 4, 30, 329, 21, $ES_UPPERCASE)\n\nGUICtrlCreateIcon(\"Icons\\Dialog-Apply.ico\", -1, 4, 4, 21, 21)\n$btnGo = GUICtrlCreateButton(\"Query\", 27, 4, 45, 21, $BS_DEFPUSHBUTTON)\nGUICtrlCreateIcon(\"Icons\\Gnome-Document-Save.ico\", -1, 74, 4, 21, 21)\n$btnSave = GUICtrlCreateButton(\"Save\", 97, 4, 45, 21)\nGUICtrlCreateIcon(\"Icons\\Gnome-Preferences-Desktop-Remote-Desktop.ico\", -1, 144, 4, 21, 21)\n$btnRC = GUICtrlCreateButton(\"Remote\", 167, 4, 45, 21)\nGUICtrlCreateIcon(\"Icons\\Gnome-Application-Exit.ico\", -1, 214, 4, 21, 21)\nGUICtrlSetState($btnRC, $GUI_DISABLE)\n$btnLO = GUICtrlCreateButton(\"Logoff\", 237, 4, 45, 21)\nGUICtrlSetState($btnLO, $GUI_DISABLE)\n;$btnADQ = GUICtrlCreateButton( \"dsQuery\", 102, 29, 45, 21 )\n\n$Tab1 = GUICtrlCreateTab(4, 56, 330, 297)\nGUICtrlSetResizing($Tab1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)\n$TabSheet1 = GUICtrlCreateTabItem(\"General\")\n\n;\tLabels\nGUICtrlCreateLabel(\"Model:\", 12, 81, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"Serial / Asset:\", 12, 105, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"BIOS Version:\", 12, 129, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"Total RAM:\", 12, 153, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"OS:\", 12, 177, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"MAC:\", 12, 201, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"IP:\", 12, 225, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"OU:\", 12, 249, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"Current User:\", 12, 273, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"Default User:\", 12, 297, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"Ping:\", 12, 321, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\n\n;\tEdit controls\n\n$editModel = GUICtrlCreateInput(\"\", 96, 81, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editSerial = GUICtrlCreateInput(\"\", 96, 105, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editBIOS = GUICtrlCreateInput(\"\", 96, 129, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editRAM = GUICtrlCreateInput(\"\", 96, 153, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editOS = GUICtrlCreateInput(\"\", 96, 177, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editMAC = GUICtrlCreateInput(\"\", 96, 201, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editIP = GUICtrlCreateInput(\"\", 96, 225, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editDN = GUICtrlCreateInput(\"\", 96, 249, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editUser = GUICtrlCreateInput(\"\", 96, 273, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editDefaultUser = GUICtrlCreateInput(\"\", 96, 297, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editPing = GUICtrlCreateInput(\"\", 96, 321, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n\n\n;\tWireless info\n$TabSheet2 = GUICtrlCreateTabItem(\"Wireless\")\n\nGUICtrlCreateLabel(\"SSID:\", 12, 81, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"BSSID:\", 12, 105, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"Signal:\", 12, 129, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"Noise:\", 12, 153, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"Channel:\", 12, 177, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\n\n;\tEdits\n\n$editSSID = GUICtrlCreateInput(\"\", 96, 81, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editBSSID = GUICtrlCreateInput(\"\", 96, 105, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editSignal = GUICtrlCreateInput(\"\", 96, 129, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editNoise = GUICtrlCreateInput(\"\", 96, 153, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editChannel = GUICtrlCreateInput(\"\", 96, 177, 228, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n\n;\tMisc info (incl. monitor)\n$TabSheet3 = GUICtrlCreateTabItem(\"Misc\")\n\n$Group1 = GUICtrlCreateGroup(\"Monitor\", 12, 86, 313, 102)\nGUICtrlCreateLabel(\"Model:\", 20, 106, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"Serial:\", 20, 130, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"Description:\", 20, 154, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\n$editDmName = GUICtrlCreateInput(\"\", 96, 106, 212, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editDmSerial = GUICtrlCreateInput(\"\", 96, 130, 212, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editDmDesc = GUICtrlCreateInput(\"\", 96, 154, 212, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n\n$Group2 = GUICtrlCreateGroup(\"Software\", 12, 190, 313, 102)\nGUICtrlCreateLabel(\"IE:\", 20, 210, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"Java RE:\", 20, 234, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\nGUICtrlCreateLabel(\"LANDesk:\", 20, 258, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\n$editVerIE = GUICtrlCreateInput(\"\", 96, 210, 212, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editVerJava = GUICtrlCreateInput(\"\", 96, 234, 212, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n$editLD = GUICtrlCreateInput(\"\", 96, 258, 212, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n\n; default printer\n\nGUICtrlCreateLabel(\"Printer:\", 20, 300, 70, 17)\nGUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)\n$editPrinter = GUICtrlCreateInput(\"\", 96, 300, 212, 22, BitOR($ES_AUTOHSCROLL, $ES_READONLY))\n\n;\tEnd tab section\nGUICtrlCreateTabItem(\"\")\nGUISetState(@SW_SHOW)\n;$background = GUICtrlCreatePic( \"c:\\temp\\osxclonebg.jpg\", 0, 0, 350, 274)\n\nGUICtrlSetTip($btnGo, \"Attempt to query the specified computer.\")\nGUICtrlSetTip($btnSave, \"Save all fields to \" & $pathSave & \"COMPUTERNAME-\" & @YEAR & @MON & @MDAY & \".txt\")\nGUICtrlSetTip($btnRC, \"Start a remote control session with the specified computer.\")\nGUICtrlSetTip($btnLO, \"Logoff the current user (please make sure nobody is using it before doing this!!!).\")\n\n$statusBar = _GUICtrlStatusBar_Create($frmInfo)\n; try to make a dynamically-sized status size\nDim $StatusBar1_PartsWidth[2] = [StringLen(_NowTime(5) & \" >\") * 6.5, -1]\n_GUICtrlStatusBar_SetParts($statusBar, $StatusBar1_PartsWidth)\n_GUICtrlStatusBar_SetText($statusBar, _NowTime(5) & \" >\", 0)\n_GUICtrlStatusBar_SetText($statusBar, \"\", 1)\n_GUICtrlStatusBar_SetMinHeight($statusBar, 20)\n#EndRegion ### END Koda GUI section ###\n\nDim $goState, $logoffCheck\n\nWhile 1 ; main loop\n\t$guiMsg = GUIGetMsg()\n\n\tSelect\n\t\t; Close window\n\t\tCase $guiMsg = $GUI_EVENT_CLOSE\n\t\t\tGUIDelete()\n\t\t\tExit\n\t\t\t; Save info\n\t\tCase $guiMsg = $btnSave\n\n\t\t\t; Check that model field isn't blank\n\t\t\tIf GUICtrlRead($editModel) <> \"\" Then\n\t\t\t\tDim $stateWrite, $file\n\n\t\t\t\tIf Not FileExists($pathSave) Then\n\t\t\t\t\tDirCreate($pathSave)\n\t\t\t\tEndIf\n\n\t\t\t\t; this needs to be updated for all fields\n\t\t\t\t$stateWrite = FileWrite($pathSave & GUICtrlRead($editComp) & \"-\" & @YEAR & @MON & @MDAY & \".txt\", _\n\t\t\t\t\t\t\"-( General )------------------------------\" & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editModel) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editSerial) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editBIOS) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editRAM) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editOS) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editMAC) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editIP) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editDN) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editUser) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editDefaultUser) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editPing) & @CRLF & _\n\t\t\t\t\t\t\"-( Wireless )-----------------------------\" & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editSSID) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editBSSID) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editSignal) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editNoise) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editChannel) & @CRLF & _\n\t\t\t\t\t\t\"-( Monitor )------------------------------\" & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editDmName) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editDmSerial) & @CRLF & _\n\t\t\t\t\t\tGUICtrlRead($editDmDesc))\n\n\t\t\t\tIf $stateWrite Then\n\t\t\t\t\tupStatus(\"Info saved to [ \" & $pathSave & GUICtrlRead($editComp) & \"-\" & @YEAR & @MON & @MDAY & \".txt ]\")\n\t\t\t\tElse\n\t\t\t\t\tupStatus(\"Could not write file to [ \" & $pathSave & GUICtrlRead($editComp) & \"-\" & @YEAR & @MON & @MDAY & \".txt ]\", 1)\n\t\t\t\tEndIf\n\n\t\t\tElse\n\t\t\t\tupStatus(\"No data to write!\", 1)\n\t\t\tEndIf\n\n\t\t\t; Start the WMI query\n\t\tCase $guiMsg = $btnGo\n\t\t\tGUISetState(@SW_DISABLE)\n\t\t\t$goState = _go()\n\t\t\tGUISetState(@SW_ENABLE)\n\t\t\tWinActivate($frmInfo)\n\t\t\t; Start a LANDesk remote session\n\t\tCase $guiMsg = $btnRC\n\t\t\tIf GUICtrlRead($editComp) <> \"\" Then\n\t\t\t\tSelect\n\t\t\t\t\tCase $goState = 1\n\t\t\t\t\t\tDim $rcWin = _IECreate(\"http://landesk/RemoteSession.aspx?machine=\" & _\n\t\t\t\t\t\t\tGUICtrlRead($editComp) & \"&operation=rc\", 0, 0)\n\t\t\t\t\t\t_IEQuit($rcWin)\n\t\t\t\t\t\t$goState = 0\n\t\t\t\t\tCase $goState = 2\n\t\t\t\t\t\tupStatus(\"Computer was not contactable.\", 1)\n\t\t\t\t\tCase $goState = 0\n\t\t\t\t\t\tupStatus(\"Please query the computer first.\", 1)\n\t\t\t\tEndSelect\n\t\t\tElse\n\t\t\t\tupStatus(\"Please enter a computer name.\", 1)\n\t\t\tEndIf\n\t\t\t; Run the logoff process if user clicks 'Yes' to the msgbox\n\t\tCase $guiMsg = $btnLO\n\t\t\tIf GUICtrlRead($editComp) <> \"\" And GUICtrlRead($editUser) <> \"\" Then\n\t\t\t\t$logoffCheck = MsgBox(51, \"Remote WMI Info\", \"This will log off the current user: \" & _\n\t\t\t\t\t_currentUser(GUICtrlRead($editComp)) & \".\" & @CRLF & @CRLF & \"Have you checked \" & _\n\t\t\t\t\t\"that the computer is not in use?\")\n\t\t\t\tIf $logoffCheck = 6 Then\n\t\t\t\t\tShellExecute(\"psTools\\psshutdown.exe\", \"-o \\\\\" & GUICtrlRead($editComp))\n\t\t\t\tEndIf\n\t\t\tElse\n\t\t\t\tMsgBox(0, \"\", \"No computer entered or no user currently logged on.\")\n\t\t\tEndIf\n\t\t\t#cs\n\t\t\t\tCase $guiMsg = $btnADQ\n\t\t\t\tif GUICtrlRead($editComp) <> \"\" Then\n\t\t\t\tShellExecute( \"rundll32\", \"dsquery,OpenQueryWindow\" )\n\t\t\t\tWinWaitActive( \"Find Users\" )\n\t\t\t\tControlCommand( \"Find Users\", \"\", 16897, \"SelectString\", 'Computers' )\n\t\t\t\tSleep(2000)\n\t\t\t\tWinWait( \"Find Computers\" )\n\t\t\t\tControlSetText( \"Find Computers\", \"\", 1224, GUICtrlRead($editComp) )\n\t\t\t\tControlClick( \"Find Computers\", \"\", 16901 )\n\t\t\t\tEndIf\n\t\t\t#ce\n\n\tEndSelect\n\n\tSleep(10)\n\nWEnd ; <== main loop\n\nFunc _go()\n\t$compName = GUICtrlRead($editComp)\n\n\t; Populate the array with WMI info, if possible\n\t$info = _wmiInfo($compName)\n\n\tSelect\n\t\t; Ping failed\n\t\tCase @error = 7\n\t\t\tupStatus($info, 1)\n\t\t\tguiFlash($editComp, 0xFF0000, 200)\n\t\t\tReturn 2\n\t\t\t; Computername contained illegal characters\n\t\tCase @error = 8\n\t\t\tupStatus(\"Please enter a valid name.\", 1)\n\t\t\tguiFlash($editComp, 0xFF0000, 200)\n\t\t\tReturn 2\n\t\t\t; Unable to get WMI info from computer after successful ping (this shouldn't really happen ever)\n\t\tCase @error = 9\n\t\t\tupStatus(\"Unable to retrieve computer info after \" & Round(@extended / 1000, 1) & \"s.\", 1)\n\t\t\tguiFlash($editComp, 0xFF0000, 200)\n\t\t\tReturn 2\n\t\t\t; Everything OK? DISPLAY THE INFO THEN DAMN\n\t\tCase Not @error\n\t\t\tupStatus($compName & \" queried in \" & $info[5])\n\t\t\tIf Not WinActive($frmInfo) Then\n\t\t\t\tWinFlash($frmInfo, \"\", 4, 250)\n\t\t\tElse\n\t\t\t\tguiFlash($editComp, 0x00FF00, 200)\n\t\t\tEndIf\n\n\t\t\t; general info\n\t\t\tGUICtrlSetData($editModel, $info[0])\n\t\t\tGUICtrlSetData($editSerial, $info[1] & \" / \" & $info[10])\n\t\t\tGUICtrlSetData($editBIOS, $info[2])\n\t\t\tGUICtrlSetData($editRAM, $info[3] & \" GB\")\n\t\t\t; Set field BkColor to red if below 1 GB\n\t\t\tIf $info[3] < 0.98 Then\n\t\t\t\tGUICtrlSetBkColor($editRAM, 0xEECCCC)\n\t\t\tElse\n\t\t\t\tGUICtrlSetBkColor($editRAM, Default)\n\t\t\tEndIf\n\t\t\tGUICtrlSetData($editOS, $info[4])\n\t\t\t; Set field BkColor to red if not Windows XP\n\t\t\tIf Not StringInStr($info[4], \"XP\") Then\n\t\t\t\tGUICtrlSetBkColor($editOS, 0xEECCCC)\n\t\t\tElse\n\t\t\t\tGUICtrlSetBkColor($editOS, Default)\n\t\t\tEndIf\n\t\t\tGUICtrlSetData($editMAC, $info[9])\n\t\t\tGUICtrlSetData($editDN, $info[8])\n\t\t\tGUICtrlSetData($editUser, $info[6]); & \" (\" & _ADDNToDisplayName($info[6]) & \")\" )\n\t\t\tGUICtrlSetData($editDefaultUser, $info[7]); & \" (\" & _ADDNToDisplayName($info[7]) & \")\" )\n\t\t\tGUICtrlSetData($editPing, $info[17])\n\t\t\tGUICtrlSetData($editIP, $info[11])\n\n\t\t\t; wireless\n\t\t\tGUICtrlSetData($editSSID, $info[12])\n\t\t\tGUICtrlSetData($editSignal, $info[13])\n\t\t\tGUICtrlSetData($editNoise, $info[14])\n\t\t\tGUICtrlSetData($editChannel, $info[15])\n\t\t\tGUICtrlSetData($editBSSID, $info[18])\n\n\t\t\t; misc\n\t\t\tGUICtrlSetData($editDmName, $info[19])\n\t\t\tGUICtrlSetData($editDmSerial, $info[20])\n\t\t\tGUICtrlSetData($editDmDesc, $info[21])\n\t\t\tGUICtrlSetData($editVerIE, $info[26])\n\t\t\t; Set field BkColor to red if below v7\n\t\t\tIf StringLeft($info[26], 1) < 7 Then\n\t\t\t\tGUICtrlSetBkColor($editVerIE, 0xEECCCC)\n\t\t\tElse\n\t\t\t\tGUICtrlSetBkColor($editVerIE, Default)\n\t\t\tEndIf\n\t\t\tGUICtrlSetData($editVerJava, $info[27])\n\t\t\t; Set field BkColor to red if below v1.4\n\t\t\tIf $info[27] < 1.4 Or $info[27] = \"\" Then\n\t\t\t\tGUICtrlSetBkColor($editVerJava, 0xEECCCC)\n\t\t\tElse\n\t\t\t\tGUICtrlSetBkColor($editVerJava, Default)\n\t\t\tEndIf\n\t\t\tGUICtrlSetData($editLD, $info[28])\n\t\t\t; Set field BkColor to red if below v1.4\n\t\t\tIf $info[28] = \"Not running.\" Then\n\t\t\t\tGUICtrlSetBkColor($editLD, 0xEECCCC)\n\t\t\tElse\n\t\t\t\tGUICtrlSetBkColor($editLD, Default)\n\t\t\tEndIf\n\n\t\t\t; printer\n\t\t\tGUICtrlSetData($editPrinter, $info[29])\n\n\t\t\tGUICtrlSetTip($editUser, $info[24], $info[22], 1)\n\t\t\tGUICtrlSetTip($editDefaultUser, $info[25], $info[23], 1)\n\tEndSelect\n\n\tReturn 1\n\nEndFunc   ;==>_go\n\nExit\n\nFunc _wmiInfo($compName)\n\n\t; seterror if the computername string contains illegal characters\n\tIf Not _computerNameLegal($compName) Then\n\t\tSetError(8)\n\t\tReturn\n\tEndIf\n\n\t; init object variables\n\tDim $objWMIService, $objAccount\n\tDim $colBios, $colCSP, $colLMC, $colOS, $colNic, $colSysEnc, $colDM\n\tDim $dmEDID, $dmPNPDID, $dmName\n\tDim $arrCU\n\tDim $ping = Ping($compName, 1000)\n\n\tIf @error Then\n\t\tSelect\n\t\t\tCase @error = 1\n\t\t\t\tSetError(7)\n\t\t\t\tReturn \"Computer is offline.\"\n\t\t\tCase @error = 2\n\t\t\t\tSetError(7)\n\t\t\t\tReturn \"Computer is unreachable.\"\n\t\t\tCase @error = 3\n\t\t\t\tSetError(7)\n\t\t\t\tReturn \"Bad destination, please check the name.\"\n\t\t\tCase @error = 4\n\t\t\t\tSetError(7)\n\t\t\t\tReturn \"Problem contacting address.\"\n\t\tEndSelect\n\tEndIf\n\n\t; init arrays we'll return\n\tDim $info[31], $mInfo, $infoW, $SID\n\n\t; get IP for no good damn reason\n\tTCPStartup()\n\t$info[11] = TCPNameToIP($compName)\n\tTCPShutdown()\n\n\t; start the response timer\n\tDim $timer = TimerInit()\n\n\t; get the WIM object\n\t$objWMIService = ObjGet(\"winmgmts:\\\\\" & $compName & \"\\root\\cimv2\")\n\t;$objRegistry = ObjGet(\"winmgmts:\\\\\" & $compName & \"\\root\\default:StdRegProv\")\n\tIf $debug Then ConsoleWrite(\"Time after WMI connection: \" & TimerDiff($timer) & @CRLF)\n\t; get defaultusername & software versions from the registry\n\t$info[7] = RegRead(\"\\\\\" & $compName & \"\\HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon\", \"DefaultUserName\")\n\t$info[30] = RegRead(\"\\\\\" & $compName & \"\\HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon\", \"DefaultDomainName\")\n\t$info[26] = RegRead(\"\\\\\" & $compName & \"\\HKLM\\SOFTWARE\\Microsoft\\Internet Explorer\", \"Version\")\n\t$info[27] = RegRead(\"\\\\\" & $compName & \"\\HKLM\\SOFTWARE\\JavaSoft\\Java Runtime Environment\", \"CurrentVersion\")\n\tIf $debug Then ConsoleWrite(\"Time after registry: \" & TimerDiff($timer) & @CRLF)\n\t; check to see if the WMI object exists; if not, seterror and return\n\t; this check should now be deprecated due to the use of ping()\n\tIf Not IsObj($objWMIService) Then\n\t\tSetError(9, TimerDiff($timer))\n\t\tReturn\n\tEndIf\n\n\t$info[17] = Round($ping, -1) & \"ms\"\n\n\t; check if LD remote agent (issuser) is running\n\t$info[28] = _processExists(\"issuser.exe\", $compName)\n\n\tIf Not $info[28] Then\n\t\t$info[28] = \"Not running.\"\n\tElse\n\t\t$info[28] = \"Running (PID: \" & $info[28] & \")\"\n\tEndIf\n\n\t; execquery on all the info groups we'll need\n\t$colBios = $objWMIService.execquery(\"Select * From Win32_BIOS\")\n\t$colSysEnc = $objWMIService.execquery(\"Select * From Win32_SystemEnclosure\")\n\t$colCSP = $objWMIService.execquery(\"Select * from Win32_ComputerSystem\")\n\t$colLMC = $objWMIService.execquery(\"Select * from Win32_LogicalMemoryConfiguration\")\n\t$colOS = $objWMIService.execquery(\"Select * from Win32_OperatingSystem\")\n\t$colNic = $objWMIService.execquery(\"SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True\")\n\tIf $debug Then ConsoleWrite(\"Time after queries: \" & TimerDiff($timer) & @CRLF)\n\t$info[8] = _extractOU(_getDN($compName))\n\tIf $debug Then ConsoleWrite(\"Time after DN: \" & TimerDiff($timer) & @CRLF)\n\t; get monitor info\n\t$mInfo = monitorInfo($compName)\n\tIf $debug Then ConsoleWrite(\"Time after monitorInfo: \" & TimerDiff($timer) & @CRLF)\n\tIf IsArray($mInfo) Then\n\t\t$info[19] = $mInfo[0] ; model\n\t\t$info[20] = $mInfo[1] ; serial\n\t\t$info[21] = $mInfo[2] ; name\n\tElse\n\t\t$info[19] = \"No valid EDID found.\"\n\tEndIf\n\n\t; grab computer model & current user\n\tFor $objCSP In $colCSP\n\t\t$info[0] = StringStripWS($objCSP.Manufacturer, 2) & \" \" & $objCSP.Model\n\t\t$info[6] = $objCSP.UserName\n\tNext\n\n\t; get current user full name and description\n\tIf $info[6] <> \"\" Then\n\t\t$arrCU = StringSplit($info[6], \"\\\", 2)\n\t\t$objAccount = $objWMIService.Get('Win32_UserAccount.Name=\"' & $arrCU[1] & '\",Domain=\"' & $arrCU[0] & '\"')\n\t\tIf IsObj($objAccount) Then\n\t\t\t$info[22] = $objAccount.FullName\n\t\t\t$info[24] = $objAccount.Description\n\t\t\t$SID = $objAccount.SID\n\t\tEndIf\n\tEndIf\n\t;if $debug Then ConsoleWrite( $arrCU[1] & \" SID: \" & $SID & @CRLF )\n\n\t; get default user full name and description\n\t$objAccount = $objWMIService.Get(\"Win32_UserAccount.Name='\" & $info[7] & \"',Domain='\" & $info[30] & \"'\")\n\tIf IsObj($objAccount) Then\n\t\t$info[23] = $objAccount.FullName\n\t\t$info[25] = $objAccount.Description\n\tEndIf\n\n\t; grab the serial and BIOS version\n\tFor $objBios In $colBios\n\t\t$info[1] = $objBios.SerialNumber\n\t\t$info[2] = $objBios.SMBIOSBIOSVersion\n\tNext\n\n\t; grab the asset tag, if available (it will be on HP dc7900s and possibly others)\n\tFor $objSysEnc In $colSysEnc\n\t\t$info[10] = $objSysEnc.SMBIOSAssetTag\n\tNext\n\n\t; set to N/A if it didn't exist for returning purposes\n\tIf StringIsSpace($info[10]) Then $info[10] = \"Asset tag not set\"\n\n\t; grab RAM, convert to GB ('cause who the fuck has less than 1GB nowadays)\n\tFor $objLMC In $colLMC\n\t\t$info[3] = Round($objLMC.TotalPhysicalMemory / 1048576, 2)\n\tNext\n\n\t; grab OS\n\tFor $objOS In $colOS\n\t\t$info[4] = $objOS.Caption & \" \" & $objOS.CSDVersion\n\tNext\n\n\t; grab MAC\n\tFor $objNic In $colNic\n\t\t$info[9] = $objNic.MACAddress\n\t\t; check if static IP or not, indicating QS or otherwise special-purpose machine\n\t\t$info[16] = $objNic.DHCPEnabled\n\t\tIf $debug Then ConsoleWrite(\"DHCPEnabled: \" & VarGetType($info[16]) & \" | Length: \" & StringLen($info[16]) & @LF)\n\n\tNext\n\n\tIf $debug Then ConsoleWrite(\"Time after objWMI grabbing: \" & TimerDiff($timer) & @CRLF)\n\n\t; get wireless info if available\n\t$infoW = wirelessInfo($compName)\n\tIf $debug Then ConsoleWrite(\"Time after wireless stats: \" & TimerDiff($timer) & @CRLF)\n\n\t; ssid\n\t$info[12] = $infoW[0]\n\t; signal\n\t$info[13] = $infoW[1]\n\t; noise\n\t$info[14] = $infoW[2]\n\t; channel\n\t$info[15] = $infoW[3]\n\t; BSSID\n\t$info[18] = $infoW[4]\n\n\n\t; Strip whitespace from end of model string, 'cause there's usually a lot\n\t$info[0] = StringStripWS($info[0], 2)\n\n\t; get the TOTAL query time now\n\t$info[5] = Round(TimerDiff($timer), -1) & \"ms\"\n\n\tIf $SID Then _\n\t\t\t$info[29] = defPrinterInfo($SID, $compName)\n\n\tReturn $info\n\nEndFunc   ;==>_wmiInfo\n\nFunc _currentUser($compName)\n\tDim $objWMIService\n\tDim $colCSP\n\tDim $user\n\n\t$objWMIService = ObjGet(\"winmgmts:\\\\\" & $compName & \"\\root\\cimv2\")\n\n\tIf Not IsObj($objWMIService) Then Return\n\n\t$colCSP = $objWMIService.execquery(\"Select * from Win32_ComputerSystem\")\n\n\tFor $objCSP In $colCSP\n\t\t$user = $objCSP.UserName\n\tNext\n\n\tReturn $user\n\nEndFunc   ;==>_currentUser\n\nFunc _getDN($compName)\n\tDim $objTrans, $objDomain\n\tConst $ADS_NAME_TYPE_1779 = 1\n\tConst $ADS_NAME_INITTYPE_GC = 3\n\tConst $ADS_NAME_TYPE_NT4 = 3\n\n\t$objTranslate = ObjCreate(\"NameTranslate\")\n\t$objDomain = ObjGet(\"LDAP://rootDse\")\n\tIf @error Then\n\t\tReturn \"Could not contact domain controller.\"\n\tEndIf\n\n\t$objTranslate.Init($ADS_NAME_INITTYPE_GC, \"\")\n\t$objTranslate.Set($ADS_NAME_TYPE_NT4, @LogonDomain & \"\\\" & $compName & \"$\")\n\t$compDN = $objTranslate.Get($ADS_NAME_TYPE_1779)\n\t;Set DN to upper Case\n\t$compDN = StringUpper($compDN)\n\n\tReturn $compDN\n\nEndFunc   ;==>_getDN\n\nFunc upStatus($msg, $flash = 0, $color = 0x88DDCC)\n\t_GUICtrlStatusBar_SetText($statusBar, _NowTime(5) & \" >\", 0)\n\t_GUICtrlStatusBar_SetText($statusBar, $msg, 1)\n\n\tIf $flash Then\n\t\t;for $i=0 to 3\n\t\t;\t_GUICtrlStatusBar_SetBkColor($statusBar, $color)\n\t\t;\tSleep(500)\n\t\t;\t_GUICtrlStatusBar_SetBkColor($statusBar, $CLR_DEFAULT)\n\t\t;\tSleep(500)\n\t\t;Next\n\tElse\n\t\t_GUICtrlStatusBar_SetBkColor($statusBar, $CLR_MONEYGREEN)\n\t\tSleep(250)\n\t\t_GUICtrlStatusBar_SetBkColor($statusBar, $CLR_DEFAULT)\n\tEndIf\nEndFunc   ;==>upStatus\n\nFunc _extractOU($DN)\n\t; We want to turn this\n\t; CN=compName,OU=Group3,OU=Group2,OU=Group1,DC=site,DC=com\n\t; into this\n\t; Group3\n\t;\n\t; HAHA THIS WAS SO EASY, THANKS StringSplit()\n\tIf $DN = \"Could not contact domain controller.\" Then Return $DN\n\n\tDim $OU, $arrDN\n\t$arrDN = StringSplit($DN, \",\", 2)\n\t$OU = StringTrimLeft($arrDN[1], 3)\n\n\tReturn $OU\nEndFunc   ;==>_extractOU\n\nFunc _displayName($logon)\n\t$objDomain = ObjGet(\"LDAP://rootDse\")\n\n\t;$objDomain.\n\nEndFunc   ;==>_displayName\n\nFunc _computerNameLegal($compName)\n\tDim $i\n\tConst $illegalChars = StringToASCIIArray(\"`~!@#$ ^&*()=+[]{}\\|;:',<>/?\"\"\")\n\n\tFor $i = 0 To UBound($illegalChars) - 1\n\t\tIf StringInStr($compName, Chr($illegalChars[$i])) Then\n\t\t\t; return 0 if computer name contains bad characters\n\t\t\tReturn 0\n\t\tEndIf\n\n\tNext\n\n\t; return 1 if computer name is OK, in keeping with 1=success/0=failure autoit function return codes\n\tReturn 1\nEndFunc   ;==>_computerNameLegal\n\nFunc aboutDiag()\n\tGUISetState(@SW_DISABLE)\n\tMsgBox(64, \"About\", \"remoteWmiInfo \" & $version & @CR & _\n\t\t\t\"\u00a9 Jon Dunham 2009\" & @CR & _\n\t\t\t\"dunham.jon@gmail.com\" & @CR & @CR)\n\tGUISetState(@SW_ENABLE)\n\tWinActivate($frmInfo)\nEndFunc   ;==>aboutDiag\n\nFunc monitorInfo($compName = \".\")\n\t; Dell serial - 78 characters in (without MX0 or CN0 prefix)\n\t; HP serial - 114 characters in\n\t; both models - 96 (192 hex) characters in\n\t;\n\t; this function runs assuming the computer has already been contacted,\n\t;  otherwise it will hang for ~82 seconds trying to contact the WMI service\n\t;\n\tDim $colDM, $PNPDID, $EDID, $Name\n\tDim $objWMIService = ObjGet(\"winmgmts:\\\\\" & $compName & \"\\root\\cimv2\")\n\t$colDM = $objWMIService.execquery('SELECT * FROM Win32_DesktopMonitor WHERE PNPDeviceID IS NOT NULL')\n\n\tFor $objDM In $colDM\n\t\t; this is the best scenario we want (powered on/connected).\n\t\t;  Generally all other DesktopMonitor.Availability = 8 (off-line)\n\t\tIf $objDM.Availability = 3 Then \n\t\t\t$PNPDID = $objDM.PNPDeviceID\n\t\t\t$Name = $objDM.Name\n\t\t\t$EDID = RegRead(\"\\\\\" & $compName & \"\\HKLM\\SYSTEM\\CurrentControlSet\\Enum\\\" & $PNPDID & \"\\Device Parameters\", \"EDID\")\n\t\t\tIf Not @error Then\n\t\t\t\tExitLoop\n\t\t\t;if there isn't an EDID for this, continueloop and get it from the next monitor with a PNPDeviceID\n\t\t\tElse\n\t\t\t\tContinueLoop \n\t\t\tEndIf\n\t\t; this may or may not indicate the currently connected display device.\n\t\t;  Display status reporting seems to be sketchy at best with WMI\n\t\tElse\n\t\t\t$PNPDID = $objDM.PNPDeviceID\n\t\t\t$Name = $objDM.Name\n\t\t\t$EDID = RegRead(\"\\\\\" & $compName & \"\\HKLM\\SYSTEM\\CurrentControlSet\\Enum\\\" & $PNPDID & \"\\Device Parameters\", \"EDID\")\n\t\t\tIf Not @error Then\n\t\t\t\tExitLoop\n\t\t\tElse\n\t\t\t\tContinueLoop\n\t\t\tEndIf\n\t\tEndIf\n\tNext\n\n\tIf $debug Then ConsoleWrite($Name & \": \" & $objDM.Availability & \" \\ \" & $PNPDID & @LF & @LF & $EDID & @LF)\n\n\tIf Not IsBinary($EDID) Then\n\t\tSetError(1)\n\t\tReturn @error\n\tEndIf\n\n\tDim $info[3], $serial, $model\n\n\t$model = StringStripWS(StringMid(BinaryToString($EDID), 96, 12), 2)\n\n\tIf $debug Then ConsoleWrite(\"Model: \" & $model & @CRLF)\n\n\tSelect\n\t\tCase StringLeft($model, 2) = \"HP\"\n\t\t\tIf $debug Then ConsoleWrite(\"HP found\" & @CRLF)\n\t\t\t$serial = StringMid(BinaryToString($EDID), 114, 10)\n\t\tCase StringLeft($model, 2) = \"DE\"\n\t\t\tIf $debug Then ConsoleWrite(\"Dell found\" & @CRLF)\n\t\t\t$serial = StringMid(BinaryToString($EDID), 78, 12)\n\t\t\t$serial = \"[ MX0 | CN0 ]\" & StringLeft($serial, 5) & \"XXXXX\" & StringRight($serial, 7)\n\t\tCase StringLeft($model, 2) = \"LG\"\n\t\t\tIf $debug Then ConsoleWrite(\"LG found\" & @CRLF)\n\t\t\t$serial = StringMid(BinaryToString($EDID), 114, 12) & \" (may be the model)\"\n\tEndSelect\n\n\tIf $debug Then ConsoleWrite(\"Serial: \" & $serial & @CRLF)\n\n\t$info[0] = $model\n\t$info[1] = $serial\n\t$info[2] = $Name\n\n\tReturn $info\nEndFunc   ;==>monitorInfo\n\nFunc _processExists($procName, $compName = \".\")\n\t$oWMIService = ObjGet(\"winmgmts:\\\\\" & $compName & \"\\root\\CIMV2\")\n\n\tIf Not IsObj($oWMIService) Then\n\t\tSetError(1)\n\t\tReturn\n\tEndIf\n\n\tDim $handle, $colProc\n\n\t$cProc = $oWMIService.ExecQuery('SELECT * FROM Win32_Process WHERE Name = \"' & $procName & '\"')\n\n\tFor $oProc In $cProc\n\t\t$handle = $oProc.Handle\n\tNext\n\n\tIf $handle Then\n\t\tReturn $handle\n\tElse\n\t\tReturn 0\n\tEndIf\nEndFunc   ;==>_processExists\n\nFunc guiFlash(ByRef $control, $color, $duration = 200, $times = 2, $tween = 0.4)\n\t$sleep1 = ($duration / $times) * $tween\n\t$sleep2 = ($duration / $times) * (1 - $tween)\n\n\tIf $control <> \"\" Then\n\t\tIf IsHWnd($control) Then\n\t\t\tFor $i = 1 To $times\n\t\t\t\tGUISetBkColor($control, $color)\n\t\t\t\tSleep($sleep1)\n\t\t\t\tGUISetBkColor($control, Default)\n\t\t\t\tSleep($sleep2)\n\t\t\tNext\n\t\tElse\n\t\t\tFor $i = 1 To $times\n\t\t\t\tGUICtrlSetBkColor($control, $color)\n\t\t\t\tSleep($sleep1)\n\t\t\t\tGUICtrlSetBkColor($control, Default)\n\t\t\t\tSleep($sleep2)\n\t\t\tNext\n\t\tEndIf\n\tElse\n\t\tReturn 0\n\tEndIf\n\n\tReturn 1\nEndFunc   ;==>guiFlash\n\nFunc defPrinterInfo($SID, $compName = \".\")\n\t$defPrintString = RegRead(\"\\\\\" & $compName & \"\\HKU\\\" & $SID & \"\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\", \"Device\")\n\n\t$info = StringSplit($defPrintString, \",\", 2)\n\t$defPrinter = $info[0]\n\n\tReturn $defPrinter\nEndFunc   ;==>defPrinterInfo\n\nFunc wirelessInfo($strComputer = \".\")\n\n\tDim $objWMIService = ObjGet(\"winmgmts:\\\\\" & $strComputer & \"\\root\\WMI\")\n\n\t; Was the computer contactable?\n\tIf Not IsObj($objWMIService) Then\n\t\tReturn 2\n\tEndIf\n\n\tDim $SSID, $BSSID, $signal, $noise, $channel, $info[5]\n\tDim $raw\n\tConst $channels[24] = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"40\", \"36\", \"44\", \"48\", \"52\", _\n\t\t\"56\", \"60\", \"64\", \"149\", \"153\", \"157\", \"161\", \"165\"]\n\tConst $frequencies[24] = [\"2412000\", \"2417000\", \"2422000\", \"2427000\", \"2432000\", \"2437000\", \"2442000\", \"2447000\", _\n\t\"2452000\", \"2457000\", \"2462000\", \"5200000\", \"5180000\", \"5220000\", \"5240000\", \"5260000\", \"5280000\", \"5300000\", \"5320000\", _\n\t\"5745000\", \"5765000\", \"5785000\", \"5805000\", \"5825000\"]\n\n\t; Signal\n\n\t$colWifi = $objWMIService.ExecQuery(\"Select * From MSNdis_80211_ReceivedSignalStrength where Active = True\")\n\n\tFor $objWifi In $colWifi\n\t\t$signal = $objWifi.NDIS80211ReceivedSignalStrength & \" dBm\"\n\tNext\n\n\t; Noise\n\n\t$colWifi = $objWMIService.ExecQuery(\"SELECT * FROM Atheros5000_NoiseFloor where Active = True\")\n\n\tFor $objWifi In $colWifi\n\t\t$noise = -$objWifi.Value & \" dBm\"\n\tNext\n\n\t; SSID\n\n\t$colWifi = $objWMIService.ExecQuery(\"Select * From MSNdis_80211_ServiceSetIdentifier\")\n\n\tFor $objWifi In $colWifi\n\t\t$SSID = $objWifi.NDIS80211SSID\n\tNext\n\n\tFor $i = 0 To UBound($SSID) - 1\n\t\tIf $SSID[$i] < 32 Or $SSID[$i] > 127 Then\n\t\t\t$SSID[$i] = \"\"\n\t\tElse\n\t\t\t$SSID[$i] = Chr($SSID[$i])\n\t\tEndIf\n\tNext\n\n\t$SSID = _ArrayToString($SSID, \"\")\n\n\t; AP MAC\n\n\t$colWifi = $objWMIService.ExecQuery(\"Select * From MSNdis_80211_BaseServiceSetIdentifier WHERE Active = True\")\n\n\tFor $objWifi In $colWifi\n\t\t$BSSID = $objWifi.NDIS80211MacAddress\n\tNext\n\n\tFor $i = 0 To UBound($BSSID) - 1\n\t\t$BSSID[$i] = Hex($BSSID[$i], 2)\n\tNext\n\n\t; Channel\n\n\t$colWifi = $objWMIService.ExecQuery(\"Select * From MSNdis_80211_Configuration WHERE Active = True\")\n\n\tFor $objWifi In $colWifi\n\t\t$raw = $objWifi.Ndis80211Config.DSConfig\n\n\t\tFor $i = 0 To UBound($frequencies) - 1\n\t\t\tIf $raw = $frequencies[$i] Then\n\t\t\t\t$channel = $channels[$i]\n\t\t\tEndIf\n\t\tNext\n\n\tNext\n\n\t; Formatting (use stringreplace($info[4], \":\", \"\") to remove or replace colons in the AP MAC if desired)\n\n\t$BSSID = _ArrayToString($BSSID, \":\")\n\n\t$info[0] = $SSID\n\t$info[1] = $signal\n\t$info[2] = $noise\n\t$info[3] = $channel\n\t$info[4] = $BSSID\n\n\tReturn $info\n\nEndFunc   ;==>wirelessInfo\n\n</source>"
                    }
                ]
            }
        }
    }
}