-
Posts
11 -
Joined
-
Last visited
Everything posted by deadserious
-
Print from GUI is it possible?
deadserious replied to deadserious's topic in AutoIt General Help and Support
Universalist, thank you for taking a look at my script, yes I will agree with you my logic is a little messed up, I'm trying to get the GUI part to print once the script is ran. Is that possible? I'm not familar with how to do that. I'm just now learning how to create a gui and wanted to see if I can print the output from directly from the gui, however I did not want to save the information to a file first if that is possible, just print directly from the gui. Let me know if that is possible and if you could point me in the direction of how to script that I would really appreciate the help... thx. -
Hey there fellow AutoIt Scriptors... can anyone tell me if there is a way to print information once I run a gui and retrieve information from a PC? I'm stumped... and it's driving me mad. Any help is greatly appreciated. Here is my script... #include <GuiEdit.au3> #include <GuiConstants.au3> #include <WindowsConstants.au3> #include <File.au3> $Computer = "" $NIC ="" MyScout() Func MyScout() Local $font, $btnQry, $btnRemote, $btnSMSSoftware, $btnSMSHardware, $msg $font = "Times New Roman" $data = GUIGetMsg() GUICreate("Scout Tool", 400, 600) GUISetState(@SW_SHOW) $filemenu = GUICtrlCreateMenu("&File") $fileitem = GUICtrlCreateMenuItem("Print...", $filemenu) GUICtrlCreateLabel("Scout Tool", 10, 10, 100, 30) GUICtrlSetFont(-1, 15, 400, 2, $font) GUICtrlCreateLabel("SCCM Information", 275, 180, 100, 30) GUICtrlCreateLabel("DeadSerious" & @CRLF & _ "Script created by: DeadSerious Group" & @CRLF & "ADMJ" & _ @CRLF & "Version 1.1" & @CRLF & "Date Created: 2/4/2014", 10, 500, 300) GUICtrlCreateIcon(@scriptdir & "\scout.ico","",115,5,45,30) $hEdit = GUICtrlCreateEdit("", 10, 40,250,400) $PC = GUICtrlCreateInput("Enter Computer Name", 270, 40, 120, 25) $btnQry = GUICtrlCreateButton("Query System",270, 70, 100, 30) $btnRemote = GUICtrlCreateButton("Remote Control",270, 110, 100, 30) $btnSMSSoftware = GUICtrlCreateButton("Installed Software",270, 200, 100, 30) $btnSMSHardware = GUICtrlCreateButton("Hardware Inventory",270, 240, 100, 30) GUISetState() ;_GUICtrlEdit_AppendText($hEdit, "Date: " & @MON & "/" & @MDAY & "/" & @YEAR & @CRLF) _GUICtrlEdit_AppendText($hEdit, @CRLF & "Computer System Information") _GUICtrlEdit_AppendText($hEdit, @CRLF & "----------------------------------------------") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btnQry $Computer = GUICtrlRead($PC) If $Computer = "Enter Computer Name" Then MsgBox(16,"Error", "Please enter a Host Name before clicking on the Query button!") ElseIf $Computer = "" Then MsgBox(16,"Error", "You MUST enter a Host Name before clicking on the Query button!") Else Local $memory = _Get_Memory() / 1024 / 1024 /1024 ; <===== Gets memory information and divides by 1024 3 times Local $x = Round($memory) ; <======== Rounds off the memory to the nearest GB $NIC = "" $objWMIService = ObjGet("winmgmts:\\" & $Computer & "\root\CIMV2") _GUICtrlEdit_AppendText($hEdit, @CRLF & "Host: " & _Get_Name()) _GUICtrlEdit_AppendText($hEdit, @CRLF & "PC Model: " & _Get_SystemVendor() & " " & _Get_System_Model()) _GUICtrlEdit_AppendText($hEdit, @CRLF & "Serial Number: " & _Serial()) _GUICtrlEdit_AppendText($hEdit, @CRLF & "Memory: " & $x & " GB Memory") _GUICtrlEdit_AppendText($hEdit, @CRLF & "Last User: " & _LastUserName() & @CRLF) _GUICtrlEdit_AppendText($hEdit, @CRLF & "Operating System Information") _GUICtrlEdit_AppendText($hEdit, @CRLF & "----------------------------------------------") _GUICtrlEdit_AppendText($hEdit, @CRLF & "OS: " & _OS() & @CRLF & "OS Service Pack: " & _OS_SP()) _GUICtrlEdit_AppendText($hEdit, @CRLF & "Last Boot: " & _LastBoot()& @CRLF & @CRLF) _GUICtrlEdit_AppendText($hEdit, @CRLF & "Network Information") _GUICtrlEdit_AppendText($hEdit, @CRLF & "----------------------------------------------") _GUICtrlEdit_AppendText($hEdit, @CRLF & MyIP() & $NIC) _GUICtrlEdit_AppendText($hEdit, @CRLF & @CRLF & " <----------------------- End Query -------------------------->") _GUICtrlEdit_AppendText($hEdit, @CRLF & @CRLF & @CRLF) EndIf Case $msg = $btnRemote Remote() Case $msg = $btnSMSSoftware $Computer = GUICtrlRead($PC) Run("C:\Program Files\Internet Explorer\iexplore.exe" & " http://technet.microsoft.com") Case $msg = $btnSMSHardware Run("C:\Program Files (x86)\Internet Explorer\iexplore.exe" & " http://www.anandtech.com") Case $msg = $fileitem Print() EndSelect WEnd GUIDelete() EndFunc Func Remote() ; ================= If SCCM Remote is not installed show error ==========================================] $Remotex64 = FileExists("C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe") $Remotex86 = FileExists("C:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe") If $Computer = "" Then MsgBox(16,"Error", "Please enter a Host Name before you click on the Remote button!") ElseIf $Computer = "" Then MsgBox(0,"Error","You must enter a valid Host Name before clicking on the Remote button!") ElseIf $Remotex64 = 1 Then Run("C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe " & $Computer & " \\mysccm01") ElseIf $Remotex64 = -1 Then MsgBox(0,"Error", "SCCM Remote is not installed!") ElseIf $Remotex86 = 1 Then Run("C:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe " & $Computer & " \\mysccm01") Else MsgBox(0,"Error", "SCCM Remote is not installed!") EndIf EndFunc Func _Get_Name() ; <========== Gets Host Name of Remote PC ==========] Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($Computer, "\root\cimv2", "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT Name FROM Win32_ComputerSystem", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.name Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_System_Model() ; <======= Gets Model Name of Remote PC ===] Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($Computer, "\root\cimv2", "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Version Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_SystemVendor() ; <======== Gets Manufacturer Name or Remote PC ================] Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($Computer, "\root\cimv2", "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Vendor Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _LastUserName() ; <========= Gets LoggedOn User of Remote PC ======================] Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($Computer, "\root\cimv2", "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Username Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Serial() ; <======== Gets serial number of Remote PC ====================] Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($Computer, "\root\cimv2", "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.SerialNumber Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _OS() ; <========== Gets Operating System Name ========================] Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($Computer, "\root\cimv2", "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Caption Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _LastBoot() ; <========== Gets System Uptime of Remote PC =======================] Local $s_Text = '' $objWMIService = ObjGet("winmgmts:\\" & $Computer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery( "SELECT LastBootUpTime FROM Win32_OperatingSystem") For $objItem In $colItems Local $s_Text = $objItem.LastBootUpTime Return (StringMid($s_Text, 5, 2) & "/" & StringMid($s_Text, 7, 2) & "/" & StringLeft($s_Text, 4) & " " & StringMid($s_Text, 9, 2) & ":" _ & StringMid($s_Text, 11, 2) & ":" & StringMid($s_Text, 13, 2)) Next EndFunc Func _OS_SP() ; <========== Gets OS Service Pack installed of Remote PC =========] Local $s_Text = '' Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($Computer, "\root\cimv2", "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.ServicePackMajorVersion Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_Memory() ; <========== Gets OS Service Pack installed of Remote PC =========] Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($Computer, "\root\cimv2", "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.TotalPhysicalMemory Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_TotalMemory() ; <========= Rounds off Total Memory to GB's ==================] Local $s_Text = '' $memory = _Get_TotalMemory() / 1024 / 1024 /1024 Local $x = Round($memory) Return String($x) EndFunc Func MyIP() $objWMIService = ObjGet("winmgmts:\\" & $Computer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True', "WQL", 0x10 + 0x20) If IsObj($colItems) then For $objItem In $colItems $NIC = $NIC & "NIC: " & $objItem.Description & @CRLF $strIPAddress = $objItem.IPAddress(0) $NIC = $NIC & "IPAddress: " & $strIPAddress & @CRLF $NIC = $NIC & "MAC Address: " & $objItem.MACAddress & @CRLF & @CRLF Local $i = 0 While $i <= 10 $i = $i + 1 WEnd Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_NetworkAdapterConfiguration" ) Endif EndFunc;<========= End Get Network Configuration Func Print() Local $print = _FilePrint(MyScout()) If $print Then MsgBox(0, "Print", "The file was printed.") Else MsgBox(0, "Print", "Error: " & @error & @CRLF & "The file was not printed.") EndIf EndFunc
-
On Error Resume Next is it possible in Autoit?
deadserious replied to deadserious's topic in AutoIt General Help and Support
JLogan3o13, thanks I'll look at your suggestion and let you know... thanks for the input. -
Hello Autoit users... I'm having issues with a script that I that I created, the script gets remote system information and works great, however when a password on a remote PC is incorrect it errors out and causes the script to stop. My question is, is there a way to do a On Error Resume Next within AutoIt? Or is there something that I need to do in order for the script to continue after the error occurs? Any help would be greatly appreciated... #include <Excel.au3> Local $UserName = "Administrator" Local $Password = InputBox("Enter Password", "Please enter a Password for the remote PC.") Local $csv = FileOpen(@ScriptDir & "\Get-System-Info-ICA-FromList.csv", 1) Local $strName = FileOpen(@ScriptDir & "\Computers.txt",0) If $csv = -1 Then MsgBox(16, "Error", "Unable to open Get-System-Info-ICA-FromList.csv file to write report." & @CRLF & "Please check to see if it is already open.") Exit EndIf If $strName = -1 Then MsgBox(48, "Error", "Error Reading Computers.txt for input of computer list." & @CRLF & @CRLF & "You must have a Computers.txt File with a list of" & _ " Computers to read from in the directory where this script resides.") Exit EndIf FileWrite($csv, "Computer Name" & "," & "Vergence Version" & "," & "Citrix Version" & "," & "Manufacturer" & "," & "Model" & "," & "Operating System" & @CRLF) While 1 Local $strComputerName = FileReadLine($strName) If @error = -1 Then ExitLoop FileWrite($csv, _Get_Name() & "," & _Get_Vergence_Ver() & ", " & _Get_ICA_Ver() & "," & _Get_SystemVendor() & "," & _Get_SystemVersion() & "," & _Get_OS_Name() & @CRLF) DriveMapAdd("Z:", "\\" & $strComputerName & "\C$", 8, $strComputerName & "\" & $UserName, $Password) WEnd ; ========= Function Start ===========> Func _Get_Vergence_Ver() $Vergence = FileGetVersion("Z:\Program Files\Sentillion\Vergence Authenticator\Authenticator.exe") Return $Vergence EndFunc Func _Get_ICA_Ver() $ICA = FileGetVersion("Z:\Program Files\Citrix\ICA Client\wfica32.exe") Return $ICA EndFunc Func _Get_Name() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT Name FROM Win32_ComputerSystem", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.name Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_SystemVendor() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Vendor Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_SystemVersion() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Name Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_System_Model() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Version Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_OS_Name() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Caption Next Return String($s_Text) Else Return 0 EndIf EndFunc DriveMapDel("Z:") ;=========== Function End ===========> FileClose($csv) ; Opens file once the script has finished running. $oExcelExist = FileExists(@ScriptDir & "\Get-System-Info-ICA-FromList.csv") If $oExcelExist = 1 Then _ExcelBookOpen(@ScriptDir & "\Get-System-Info-ICA-FromList.csv") EndIf If @error = 1 Then MsgBox(0, "Error!", "Unable to Open the Excel Get-System-Info-ICA-FromList.csv file at the root of the script directory.") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "Cannot Open " $oExcelExist) Exit EndIf FileClose($strName) Here is the error I receive: H:ScriptingAutoItGetSystemInfoICAGet-System-Info-ICA-FromList.au3 (51) : ==> The requested action with this object has failed.: $objWMIService = $objWMILocator.ConnectServer($strComputerName, "rootcimv2", $strComputerName & "" & $UserName, $Password, "", "", "&H80") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "rootcimv2", $strComputerName & "" & $UserName, $Password, "", "", "&H80")^ ERROR >Exit code: 1 Time: 125.520
-
Function in Loop is it possible?
deadserious replied to deadserious's topic in AutoIt General Help and Support
-
Function in Loop is it possible?
deadserious replied to deadserious's topic in AutoIt General Help and Support
abberration Thanks for the help with this, I'm still trying to learn Autoit. The direction that you gave me helped me greatly. I appreciate your wisdom here. I do have another issue if you don't mind me asking? When I run the code it works on the list of computers that I'm running it against, however when it finds a computer in the list that has a diffent password it errors out. Is there a way to state IF At Error continue script? Your input is greatly appreciated. I attached the error just under the script, thanks again... #include <Excel.au3> Local $UserName = "Administrator" Local $Password = InputBox("Enter Password", "Please enter a Password for the remote PC.") Local $csv = FileOpen(@ScriptDir & "\Get-System-Info-ICA-FromList.csv", 1) Local $strName = FileOpen(@ScriptDir & "\Computers.txt",0) If $csv = -1 Then MsgBox(16, "Error", "Unable to open Get-System-Info-ICA-FromList.csv file to write report." & @CRLF & "Please check to see if it is already open.") Exit EndIf If $strName = -1 Then MsgBox(48, "Error", "Error Reading Computers.txt for input of computer list." & @CRLF & @CRLF & "You must have a Computers.txt File with a list of" & _ " Computers to read from in the directory where this script resides.") Exit EndIf FileWrite($csv, "Computer Name" & "," & "Vergence Version" & "," & "Citrix Version" & "," & "Manufacturer" & "," & "Model" & "," & "Operating System" & @CRLF) While 1 Local $strComputerName = FileReadLine($strName) If @error = -1 Then ExitLoop FileWrite($csv, _Get_Name() & "," & _Get_Vergence_Ver() & ", " & _Get_ICA_Ver() & "," & _Get_SystemVendor() & "," & _Get_SystemVersion() & "," & _Get_OS_Name() & @CRLF) DriveMapAdd("Z:", "\\" & $strComputerName & "\C$", 8, $strComputerName & "\" & $UserName, $Password) WEnd ; ========= Function Start ===========> Func _Get_Vergence_Ver() $Vergence = FileGetVersion("Z:\Program Files\Sentillion\Vergence Authenticator\Authenticator.exe") Return $Vergence EndFunc Func _Get_ICA_Ver() $ICA = FileGetVersion("Z:\Program Files\Citrix\ICA Client\wfica32.exe") Return $ICA EndFunc Func _Get_Name() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT Name FROM Win32_ComputerSystem", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.name Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_SystemVendor() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Vendor Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_SystemVersion() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Name Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_System_Model() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Version Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_OS_Name() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Caption Next Return String($s_Text) Else Return 0 EndIf EndFunc DriveMapDel("Z:") ;=========== Function End ===========> FileClose($csv) ; Opens file once the script has finished running. $oExcelExist = FileExists(@ScriptDir & "\Get-System-Info-ICA-FromList.csv") If $oExcelExist = 1 Then _ExcelBookOpen(@ScriptDir & "\Get-System-Info-ICA-FromList.csv") EndIf If @error = 1 Then MsgBox(0, "Error!", "Unable to Open the Excel Get-System-Info-ICA-FromList.csv file at the root of the script directory.") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "Cannot Open " $oExcelExist) Exit EndIf FileClose($strName) Here is the error I get: H:ScriptingAutoItGetSystemInfoICAGet-System-Info-ICA-FromList.au3 (51) : ==> The requested action with this object has failed.: $objWMIService = $objWMILocator.ConnectServer($strComputerName, "rootcimv2", $strComputerName & "" & $UserName, $Password, "", "", "&H80") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "rootcimv2", $strComputerName & "" & $UserName, $Password, "", "", "&H80")^ ERROR >Exit code: 1 Time: 125.520 -
Hello I'm stumped and I'm not sure if this is possible. I'm trying to pull Systems from a text file and run a number of queries and pipe the info back to an excel spreadsheet, however I'm not sure if you can add a function to a loop as listed below. Does anyone have any experience with this that they can point me in the right direction? I would really appreciate it since I'm just learning this autoit... Nice stuff but can be complicated at times. Thx... :-) #include <Excel.au3> Local $UserName = "Administrator" $Password = "Password" Local $csv = FileOpen(@ScriptDir & "\SystemInfo.csv", 1) Local $strName = FileOpen(@ScriptDir & "\Computers.txt",0) While 1 Local $strComputerName = FileReadLine($strName) If @error = -1 Then ExitLoop MsgBox(0,"Computer Name", "This is the computer name: " & $strComputerName) DriveMapAdd("Z:", "\\" & $strComputerName & "\C$", 8, $strComputerName & "\" & $UserName, $Password) Func _Get_Vergence_Ver() $Vergence = FileGetVersion("Z:\Program Files\Sentillion\Vergence Authenticator\Authenticator.exe") Return $Vergence EndFunc Func _Get_Name() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT Name FROM Win32_ComputerSystem", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.name Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_SystemVendor() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Vendor Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_SystemVersion() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Name Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_SystemVModel() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Version Next Return String($s_Text) Else Return 0 EndIf EndFunc Func _Get_OS_Name() Local $s_Text = '' $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objWMILocator.ConnectServer($strComputerName, "\root\cimv2", $strComputerName & "\" & $UserName, $Password, "", "", "&H80") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", 0x30) If (IsObj($objWMIService)) Then For $objItem In $colItems Local $s_Text = $ObjItem.Caption Next Return String($s_Text) Else Return 0 EndIf EndFunc ; Writes information to the Excel Spreadsheet in Script Director. FileWrite($csv, "ComputerName" & "," & "Vendor" & "," & "Model" & "," & "OS" & "," & "Vergence Version" & "," & @CRLF & _Get_Name() & "," & _Get_SystemVendor() & "," & _Get_SystemVersion() & "," & _Get_OS_Name() & "," & _Get_Vergence_Ver() & @CRLF) FileClose($csv) ;MsgBox(0, "Script finished", "The script named: " & @ScriptName & " finished!", 10) ; Opens file once the script has finished running. $oExcelExist = FileExists(@ScriptDir & "\SystemInfo.csv") If $oExcelExist = 1 Then _ExcelBookOpen(@ScriptDir & "\SystemInfo.csv") EndIf If @error = 1 Then MsgBox(0, "Error!", "Unable to Open the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "Cannot Open " $oExcelExist) Exit EndIf WEnd FileClose($csv) ; Opens file once the script has finished running. $oExcelExist = FileExists(@ScriptDir & "\SystemInfo.csv") If $oExcelExist = 1 Then _ExcelBookOpen(@ScriptDir & "\SystemInfo.csv") EndIf If @error = 1 Then MsgBox(0, "Error!", "Unable to Open the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "Cannot Open " $oExcelExist) Exit EndIf DriveMapDel("Z:") FileClose($strName)
-
PortQry.exe Script failing need help...
deadserious replied to deadserious's topic in AutoIt General Help and Support
Thanks mrflibblehat that seemed to work. I really appreciate it. -
Hello I'm new to autoit scripting and I was trying to script out using Microsoft's PortQuery software to test RDP sessions. Here is what I scripted in a batch file: Echo ================================================= >> C:RDP-Scan.log" Echo Date: %DATE% TIME: %TIME% >> C:RDP-Scan.log" portqry -n Computername -e 3389 >> C:RDP-Scan.log Echo ================================================= >> C:RDP-Scan.log.log" C:RDP-Scan.log.log Exit Here is what I tried to do in autoit: Run("""" & @ScriptDir & "portqry.exe -n computername -e 3389 >> """ & @ScriptDir & "PortQuery-Log.txt""") Can anyone assist me? I'm not sure what I'm doing wrong here.
-
I'm wondering if anyone can help me with this, I have a need to write a script that will allow me to open 2 Excel files, copy the value in some of the fields and paste it into another Excel file. I'm able to open the Excel files, however I cannot bring to focus the Excel file where I need to paste the info in I'm using (WinActivate) I'm not sure how to find out the file name after running the FileOpenDiolog command, it gives me the full file path and I only need the name of the file and don't really understand how to call it. Here is my code so far, please let me know what I can be doing wrong... thx so much ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Script Start - #include <Excel.au3> $message = "Please Browse to Excel Utility Calculations the Month you will be working on." $uCalc = FileOpenDialog($message, @ScriptDir & "\", "Images (*.xls; *.xlsx)", 1) ; Opens dialog box to search for Utility Calculation Excel file. If @error Then MsgBox(4096,"","No File(s) chosen") Else $uCalc = StringReplace($uCalc, "|", @CRLF) MsgBox(0,"Please Verify this is the Utility Calculations File current month","You chose the following spreadsheet " & $uCalc) EndIf $oExecel = _ExcelBookOpen($uCalc) If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist - Please Try Again!") Exit EndIf $message2 = "Please Browse to Excel Meter Read." ; Opens Second dialog box to search for Meter Read Excel File. $mRead = FileOpenDialog($message2, @ScriptDir & "\", "Images (*.xls; *.xlsx)", 1) If @error Then MsgBox(4096,"","No File(s) chosen") Else $mRead = StringReplace($mRead, "|", @CRLF) ; this is where I'm taking the information from **************************** MsgBox(4096,"This should be the Meter Read Excel File.","You chose " & $mRead) EndIf $oExecel2 = _ExcelBookOpen($mRead) If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist - Please Try Again!") Exit EndIf ; End of opening Excel Files. ; Attempt to read file cells $sCellValue = _ExcelReadCell($oExecel2, 2, 2) ;Reads Meter Read Excel File Cell B2 and displays in dialog box. MsgBox(0,"", "Corp Yard: " & $sCellValue) MsgBox(0, "", $uCalc) WinActivate("[CLASS:XLMAIN]", $uCalc)
-
Hey Everyone, I have an issue maybe someone can assist with this. I created a script to remotely shutdown a group of computers, the script has an option to abort the shutdown, however the popup message goes behind the message stating that the computer is shutting down. Is there a way to move the message box to the top corner of a screen and make it active? I tried this with notepad, I just can't seem to figure out how to do it with the message box that comes up in the script. Here is the script for notepad ************************************************************************ Run("notepad") Sleep(500) WinMove("Untitled - Notepad", "", 20, 20,) ************************************************************************ This is the script to shutdown the computer ************************************************************************ ; Prompt user to run the script - use a Yes/No prompt $answer=MsgBox(4, " Abort the Shutdown?", "Click Yes to abort the shutdown process.") WinMove("MsgBox 4", "", ,20, 20) ; Check User's answer ; If "No" was selected click (7) then exit the script if $answer=7 Then MsgBox(0, "Do you want to Abort the Shutdown?", "Computer will continue to shutdown") Exit EndIf Run("c:\windows\system32\psshutdown -a") ********************************************************************* Any Assistance is greatly appreciated. Deadserious