gtifsi Posted June 15, 2010 Share Posted June 15, 2010 Hello, I've written an Autoit script that will pull various information from a computer (Disk space, OS Ver, SP, etc...) and it works great. The problem comes when I try using Autoit or any other application to run the script on a list of computers. The goal here is to stop having to log in to my 50+ servers to retrieve the information. I've tried telling the script to run using PSexec (http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx) however it has not worked. I tried this with and without domain credentials. PSexec will start the task (the process shows up in task manager) however the script doesn't actually run. Does anyone have suggestions on how to fix this? Or just a better way to do it? Here is my info collection script: expandcollapse popup#Include <File.au3> ;Check if the file exists, if not then create it. IF Not FileExists("\\MY LOCATION\Drives.txt") Then _FileCreate("\\MY LOCATION\Drives.txt") MsgBox(0, "File", "Created the text file.") EndIf $file = FileOpen("\\MY LOCATION\Drives.txt", 1) ; Write the computer's OS version and service pack to the opened file. FileWrite($file, @CRLF & @ComputerName & @CRLF & "OS Version: " & @OSVersion & @CRLF & "Service Pack: " & @OSServicePack & @CRLF) If $file = -1 Then ;Check if the file is open to write to. MsgBox(0, "Error", "Unable to open file.") EndIf ; Retrieve all of the local fixed drives and put them in an array. $var = DriveGetDrive( "Fixed" ) If @error Then MsgBox(4096,"", "No drives were found.") EndIf ; For every drive found, get it's size and free space, then write both values to the open file. For $i = 1 To (UBound($var, 1) -1) TrayTip("Processing...", "Retrieving information on drive: " & StringUpper($var[$i]) & " from " & $var[0] & " total drives.", 30) Sleep(2000) $e1 = DriveSpaceTotal($var[$i]) / 1000 $e2 = DriveSpaceFree($var[$i]) / 1000 FileWrite($file, "Drive Letter: " & StringUpper($var[$i]) & @CRLF & "Total Space: " & Round($e1, 1) & @CRLF & "Free Space: " & Round($e2, 1) & @CRLF) Next FileClose($file) TrayTip("Completed!", "Drive information collection completed for " & $var[0] & " drives.", 30) Sleep(3000) Link to comment Share on other sites More sharing options...
happy2help Posted June 16, 2010 Share Posted June 16, 2010 Finally! It looks like i can help someone else with a script that i use daily! I run a file called FolderMonitor.au3 on all my machines i want to monitor.(8 or 9 i think). This runs all the time and monitors a shared folder. When i copy a file into that folder, FolderMonitor.au3 then runs the script file and , on completion, deletes the file.(this is so it doesn't rerun it a few minutes later). I have just added the function to restart the script if it detects a newer version of the file. So FolderMonitor.au3 sits there running all the time, when it detects a new file in the folder, it runs it and deletes it and if it finds a newer version of itself, it restarts. I hope this helps you (or anyone else) and if anyone can suggest improvements, i'm open.Scripts.rar Link to comment Share on other sites More sharing options...
UEZ Posted June 16, 2010 Share Posted June 16, 2010 What about using WMI? BR, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
UEZ Posted June 16, 2010 Share Posted June 16, 2010 Example: expandcollapse popupGlobal $ip = "localhost" If $CmdLine[0] > 0 Then $ip = $CmdLine[1] $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $ip & "\root\cimv2") _WMI($ip) Exit Func _WMI($srv) Local $ping, $colItems, $objItem, $ComputerName, $OS, $SP, $Disk, $Disk_Caption, $Disk_FreeSpace, $Disk_Perc_Free, $Disk_Size $ping = Ping($srv) If $ping Then $colItems = $objWMIService.ExecQuery("Select CSName, Caption, CSDVersion from Win32_OperatingSystem", "WQL", 0x30) If IsObj($colItems) Then For $objItem In $colItems $ComputerName = $objItem.CSName $OS = $objItem.Caption $SP = $objItem.CSDVersion Next ConsoleWrite($ComputerName & @CRLF & $os & @CRLF & $SP & @CRLF & @CRLF) EndIf $colItems = $objWMIService.ExecQuery("Select Caption, FreeSpace, MediaType, Size from Win32_LogicalDisk Where MediaType = '12'", "WQL", 0x30) ;get fixed harddisk media If IsObj($colItems) Then For $objItem In $colItems If $objItem.Size > 0 And $objItem.MediaType <> "" Then $Disk_Caption = $objItem.Caption $Disk_FreeSpace = Round($objItem.FreeSpace / 1024 ^ 3, 2) $Disk_Size = Round($objItem.Size / 1024 ^ 3, 2) $Disk_Perc_Free = Round(100 * $objItem.FreeSpace / $objItem.Size, 2) $Disk &= $Disk_Caption & @CRLF & $Disk_Size & @CRLF & $Disk_FreeSpace & @CRLF EndIf Next ConsoleWrite($Disk & @CRLF & @CRLF) EndIf Else Return "Host not reachable" EndIf EndFunc BR, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
gtifsi Posted June 16, 2010 Author Share Posted June 16, 2010 What about using WMI?BR,UEZThanks UEZ, that works great. Much appreciated.gtifsi 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