Euphoria Posted August 14, 2013 Share Posted August 14, 2013 (edited) Hi, I am trying to use attached script to capture SID/User Name value on a remote PC. However when running this it does not read the input from GUI and as a result gives a blank result.... I am new to scripting and this is my first use of AutoIT. Any help would be greatly appreciated. SID18.au3 Edited August 14, 2013 by pankajmi01 Link to comment Share on other sites More sharing options...
BrewManNH Posted August 14, 2013 Share Posted August 14, 2013 You gather the user name and the computer name, but you never do anythiing with either of them in your Run command., Start there. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Euphoria Posted August 14, 2013 Author Share Posted August 14, 2013 (edited) I tried to update the Run cmd as below: Local $text = '', $Pid = Run('"' & @ComSpec & '" /c ' & $command & $ComputerName_read & $SIDUserName_read, '', @SW_HIDE, 2 + 4) Would this be the right one to use ....... as this comes out blank as well. Thanks for replying. Edited August 14, 2013 by pankajmi01 Link to comment Share on other sites More sharing options...
BrewManNH Posted August 14, 2013 Share Posted August 14, 2013 Try this, this assumes that psgetsid is in the same folder as your script, if it's not you need the full path to the exe to get it to run. expandcollapse popup#include <ButtonConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $ComputerName, $SIDUserName, $Check, $ComputerName_read, $SIDUserName_read #region ### START Koda GUI section ### Form=c:\users\pankajmi\desktop\is\autoit - pankaj\koda files\sidchecker.kxf $Form1_1 = GUICreate("SID Checker V1.0 Agneepath", 613, 145, 192, 124) GUICtrlCreateLabel("Computer Name", 16, 8, 80, 17) $ComputerName = GUICtrlCreateInput("", 16, 32, 233, 21) GUICtrlCreateLabel("SID/User Name", 16, 64, 80, 17) $SIDUserName = GUICtrlCreateInput("", 16, 88, 569, 21) $Check = GUICtrlCreateButton("Check", 268, 112, 97, 25) GUICtrlSetOnEvent(-1, "_getDOSOutput") GUICtrlSetState(-1, $GUI_FOCUS) $InputCommandResult = GUICtrlCreateEdit("", 8, 344, 649, 140, $ES_AUTOVSCROLL + $WS_VSCROLL) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select Case $msg = $Check $ComputerName_read = GUICtrlRead($ComputerName) $SIDUserName_read = GUICtrlRead($SIDUserName) _getDOSOutput("psgetsid.exe", $ComputerName_read, $SIDUserName_read) Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd ConsoleWrite(_getDOSOutput("psgetsid.exe") & @CRLF) Func _getDOSOutput($command, $computer = @ComputerName, $user = @UserName) Local $text = '', $Pid = Run('"' & @ComSpec & '" /c ' & $command & " \\" & $computer & " " & $user, '', @SW_HIDE, 2 + 4) While 1 $text &= StdoutRead($Pid) If @error Then ExitLoop Sleep(10) WEnd MsgBox(0, "SID for User Name", $text) Return StringStripWS($text, 7) EndFunc ;==>_getDOSOutput Euphoria 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Euphoria Posted August 14, 2013 Author Share Posted August 14, 2013 (edited) Hi, Thanks for the correction .. it did work as planned.... However while closing the GUI it gets me another popup message giving SID for my machine (I do not really wish to get this info). Plus while checking for a remote computer which is not reachable I planned to get a message popping up the error "Host is not reachable" or something like that. You have been kind enough.. can you please also help me with this..... I really do not want to ask that much but I learnt good tips from you which gonna help a lot..much appreciated. Edited August 14, 2013 by pankajmi01 Link to comment Share on other sites More sharing options...
BrewManNH Posted August 14, 2013 Share Posted August 14, 2013 (edited) You get the second popup because you have a ConsoleWrite after the While loop. I added 2 parameters to the _getDOSOutput function for the computer name and the user name, I also set their default values to the current computer and current user on the computer. If I were you I would remove the MsgBox in the function and have the function return the text instead, this way you can do what you want with it afterwards, and there's no annoying pop up in the function itself. Here's an updated script with some basic error checking, and it pings the computer to see if it's alive. expandcollapse popup;~ #include <ButtonConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> ;~ #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $ComputerName, $SIDUserName, $Check, $ComputerName_read, $SIDUserName_read #region ### START Koda GUI section ### Form=c:\users\pankajmi\desktop\is\autoit - pankaj\koda files\sidchecker.kxf $Form1_1 = GUICreate("SID Checker V1.0 Agneepath", 613, 145, 192, 124) GUICtrlCreateLabel("Computer Name", 16, 8, 80, 17) $ComputerName = GUICtrlCreateInput("", 16, 32, 233, 21) GUICtrlCreateLabel("SID/User Name", 16, 64, 80, 17) $SIDUserName = GUICtrlCreateInput("", 16, 88, 569, 21) $Check = GUICtrlCreateButton("Check", 268, 112, 97, 25) GUICtrlSetState(-1, $GUI_FOCUS) $InputCommandResult = GUICtrlCreateEdit("", 8, 344, 649, 140, $ES_AUTOVSCROLL + $WS_VSCROLL) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select Case $msg = $Check $ComputerName_read = GUICtrlRead($ComputerName) $SIDUserName_read = GUICtrlRead($SIDUserName) MsgBox($MB_SYSTEMMODAL, "SID for User Name: " & $SIDUserName_read, _getDOSOutput("psgetsid.exe", $ComputerName_read, $SIDUserName_read)) Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func _getDOSOutput($command, $computer = @ComputerName, $user = @UserName) Local $text = '' If Ping($computer) Then Local $Pid = Run($command & " \\" & $computer & " " & $user, "", @SW_HIDE, 2 + 4) If Not @error Then While 1 $text &= StdoutRead($Pid) If @error Then ExitLoop Sleep(10) WEnd Else $text = "An error occurred running PSGetSID.exe, the error returned was: " & @error EndIf Else $text = "Computer not reachable, error returned was: " & @error EndIf Return $text EndFunc ;==>_getDOSOutput Edited August 14, 2013 by BrewManNH Euphoria 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Euphoria Posted August 14, 2013 Author Share Posted August 14, 2013 This has been quite a learning for a newbie for scripting. This would also help me a long way providing hints to a new tool I was trying to create besides. I really do not know how to thank you BrewManNH (באָבקעס מיט קודוצ׳ה).. you really are a savior .... . Link to comment Share on other sites More sharing options...
BrewManNH Posted August 14, 2013 Share Posted August 14, 2013 You're welcome, glad it could help. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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