JCEF Posted June 12, 2014 Posted June 12, 2014 Good night!I have a script to add computers to the domain (works almost as I want), but at the beginning of the script I want to check if the account "Administrator" has a configured password (not blank). If the password is set (I do not want to know what password is set) the script continues normally, but if the password is not set the script stops and warns me that the password has to be defined.This will serve to no computer is delivered to the end user of the company where I work without the password is properly configured (on some computer models the administrator password is already configured in the image file for replication, but other models are not defined).I have done several searches and could not find solution.OS: WindowsSince now, thank you all the help you can give me. Something like this: Local $PassAdminSet ; Code to check if the administrator password is set ; If password not set: $PassAdminSet = "NotSet" If $PassAdminSet = "NotSet" Then MsgBox(16, "Error:", "The administrator password is not set!" & @CRLF & "Fix this problem and then restart this script!") Exit EndIf
Solution spudw2k Posted June 13, 2014 Solution Posted June 13, 2014 (edited) For your consideration: '?do=embed' frameborder='0' data-embedContent>> edit: OS: Windows If it wasn't, you'd be in the wrong place. Sorry...couldn't resist. Edited June 13, 2014 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
BrewManNH Posted June 13, 2014 Posted June 13, 2014 Why not just run a script to set the password instead of checking to see if it has one or not? Shouldn't they all have the same password for the Administrator account anyways? 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
JCEF Posted June 13, 2014 Author Posted June 13, 2014 Why not just run a script to set the password instead of checking to see if it has one or not? Shouldn't they all have the same password for the Administrator account anyways? Hello, BrewManNH!Effectively, it is a good idea and I intend to do this, but I want to set the password only in cases that are not defined (pure laziness).Thanks for your suggestion.
JCEF Posted June 13, 2014 Author Posted June 13, 2014 (edited) For your consideration: '?do=embed' frameborder='0' data-embedContent>> edit: If it wasn't, you'd be in the wrong place. Sorry...couldn't resist. Hello, spudw2k!Windows of course: what a fool I am.I consulted the topic you have indicated to me and helped me a lot.I do not know if it's the most correct way to do this, but I will implement as below.exemple: Local $PassAdminSet $PassAdminSet = CheckPassAdminSet() ConsoleWrite($PassAdminSet & @CRLF) If $PassAdminSet = "NotSet" Then MsgBox(16, "Error:", "The administrator password is not set!" & @CRLF & "Fix this problem and then restart this script!") Exit EndIf Func CheckPassAdminSet() Local $sUserName = "Administrator" Local $sPassword = "" Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, 0, "cmd /c", "", @SW_HIDE) ProcessClose($iPID) If $iPID > 0 Then Return "NotSet" Else Return $iPID EndIf EndFunc ;==>CheckPassAdminSet Thank you all for your help. Edited June 13, 2014 by JCEF
BrewManNH Posted June 13, 2014 Posted June 13, 2014 Hello, BrewManNH!Effectively, it is a good idea and I intend to do this, but I want to set the password only in cases that are not defined (pure laziness).Thanks for your suggestion. Setting the password to the password it's supposed to be is being lazier than testing to see if the password is set, and then setting it. Just set the password for everyone's computer and then you never have to worry about it again. If your computers are using Active Directory and Group Policy you could create it as a startup script so that it gets applied to every computer as they boot up. 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
spudw2k Posted June 13, 2014 Posted June 13, 2014 I won't contend that it is not more of a difficult IT management problem, but I would discourage from using a standardized password on every device or common device (desktop, server, switch, etc.). One compromise turns into many. Some sort of tool to generate passwords based on a hardware key (such as MAC or CPUID) and user entered key (such as a month/year for example) would be much better from a security perspective. Now I'm not talking about sophisticated attacks or physical access password cracking/reset tools--that's a whole discussion on it's own--but safeguarding against low-tech exploits (such as written down passwords) is a worthy cause if the data is worth taking the measures to protect. Just my three cents. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
BrewManNH Posted June 13, 2014 Posted June 13, 2014 Everywhere I've worked has always used a single password for the Administrator accounts for all machines. They regularly change them, but all the computers would have the same one. I can't imagine the nightmare trying to support computers with dynamic admin passwords, you'd either have to keep a database of them, or the techs would have to carry around the tool everytime they wanted to access a machine using the administrator account, and even then remote admin would be made even harder. Sometimes you don't want to log into a machine with your admin credentials because if your profile is stored somewhere that's not local to the machine, it can take a long time to log in. 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
JCEF Posted June 15, 2014 Author Posted June 15, 2014 (edited) Good night!First of all, I want to thank you for your comments which I consider as a source of knowledge.In previous threads I have not given all the information.I'm not full domain administrator in my company. I can not manage Active Directory or Group Policy. Basically, I can only administer client computers from one of several "OUs" of domain. I can add or remove computers of this "OU", install or uninstall software on those computers, either by logging into the local administrator account, either by logging into my domain account (obviously with more privileges than the common user).Effectively, all the computers in this "OU" have the same password for access to the local administrator account, however when we create image files for replication in some computer models we forget to set this password. For these cases, when we add the computer to the domain, we manually set the password, but I'm afraid we can ever forget us. So I want a mechanism to correct this omission. I want, when run the script to add the computer to the domain, if the script sees that the password is not configured notify the user and ask him if he wants to set the password at this time. And also I did not want to save the password in the script and I do not want to keep asking the user to set the password, even when it is already set.Many thanks to both! Edited June 15, 2014 by JCEF
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