anil_funny143 Posted November 14, 2018 Share Posted November 14, 2018 1. Hello, 2. My system's username is Administrator and I want to change its password from an exe which is compiled by Auto IT script. (Ex. ChangePassword.exe [from 3rd line]) 3. I want an AutoIT script (Ex.Password.au3) which I'll compile into exe (Password.exe) and when I launch that exe it should ask me to enter a password for Administrator and get compiled into another exe (ChangePassword.exe [2nd line]) Link to comment Share on other sites More sharing options...
Developers Jos Posted November 14, 2018 Developers Share Posted November 14, 2018 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 14, 2018 Developers Share Posted November 14, 2018 (edited) Welcome, so what exactly is the question? Jos Edited November 15, 2018 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ModemJunki Posted November 14, 2018 Share Posted November 14, 2018 Hmmm.. well ok, I'm willing to respond: 1. Hello! 2. You can automate the command line for the "NET" command in Windows, as instructed at many places on the Internet: https://www.makeuseof.com/tag/quick-tip-change-the-windows-user-password-via-command-line/ 3. AutoIT is perfect for what you need and I can see how you might do both of the tasks you wish, but you'll have to try a little bit on your own to write some code. I would tackle this project as follows: a. Create a script to automate the NET command to set a new password. This could be very simple, it depends on the level of error-checking or logging you wish to make. b. Create a script which can modify the password-change AutoIT script by having a small GUI with an input-box, capture the password you type in, write the password to a copy of the above script with something like the function FileWriteLine, and then compile it. This is a little more complicated but should not be too cumbersome. I hope this helps, post examples of what you try and maybe we can help you. Always carry a towel. Link to comment Share on other sites More sharing options...
anil_funny143 Posted November 15, 2018 Author Share Posted November 15, 2018 @ModemJunki Thank you for responding on my query. I can do that using NET USER in batch file which is generating another batch and can fulfill my requirement but I want that generated batch to be self-converted into exe as the batch has the password in plain text, therefore looking for AutoIT. Can you please help me with the code in AutoIT? Link to comment Share on other sites More sharing options...
ModemJunki Posted November 15, 2018 Share Posted November 15, 2018 6 hours ago, anil_funny143 said: Can you please help me with the code in AutoIT? I will help if you try on your own and post your code. If you can write batch files you can learn AutoIT and then you will have a powerful tool in your knowledge base. Always carry a towel. Link to comment Share on other sites More sharing options...
anil_funny143 Posted November 20, 2018 Author Share Posted November 20, 2018 I've tried myself but getting the syntax error at line six. Please refer my code and help me. #include"File.au3" Global $Password MsgBox(0, "Password Tool" ,"This will create a new password for ADMIN") $Password = InputBox("New Password", "Please Enter a new password for ADMIN") $File = FileOpen(@DesktopDir&"Pass.au3",1) FileWriteLine($File,"RunWait(@ComSpec & " /c " & "NET USER IDR-ADMIN " & $Password)") FileClose($File) MsgBox(0,"Success","Created the file") desktop then what would be next lines of code that generates an exe for that pass.au3 Link to comment Share on other sites More sharing options...
Danp2 Posted November 20, 2018 Share Posted November 20, 2018 8 hours ago, anil_funny143 said: FileWriteLine($File,"RunWait(@ComSpec & " /c " & "NET USER IDR-ADMIN " & $Password)") You need to wrap the parameter in single quotes to prevent Autoit from trying to evaluate the string -- FileWriteLine($File,'"RunWait(@ComSpec & " /c " & "NET USER IDR-ADMIN " & $Password)"') Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ModemJunki Posted November 20, 2018 Share Posted November 20, 2018 (edited) @Danp2 That didn't work for me. I got bored so... I recall that sometimes keeping track of when to use "'" or '"' (see, even here it's hard to read) can be confusing when you start out... so I set some global variables and assemble them into the command string later. Plus a little error checking and some message boxes sprinkled in and an option to have the inputted password show like "********" in case someone is looking over your shoulder. Probably this could be better but I don't know how fancy you need it to be. For example, you can have the written script do other things - FileWriteLine is not the only way, _FileWriteToLine can be used to make the change in a specific line of the target-file. @anil_funny143 You don't mention if the password needs to be a certain number of characters minimum? For this you have to write more conditional checking and have a loop for it, I think. Now it's time for lunch. A falafel would hit the spot... expandcollapse popup#pragma compile(inputboxres, true) #include <File.au3> Global $s_pssPreStr = 'RunWait(@ComSpec & " /c " & "NET USER IDR-ADMIN ' Global $s_pssPstStr = '")' Global $s_pssFil = "pass.au3" If FileExists($s_pssFil) Then If FileDelete($s_pssFil) Then _doCreatePass() Else MsgBox(0, "Fail", "Failed to delete existing pass file") EndIf Else _doCreatePass() EndIf Func _doCreatePass() $Psswd = InputBox("New Password", "Please Enter a new password for IDR-ADMIN") ;~ $Psswd = InputBox("New Password", "Please Enter a new password for IDR-ADMIN", "", "*") ; try that for a little bit of privacy If @error = 1 Then ; you pressed the Cancel button MsgBox(4096, "Cancel", "The operation was canceled") Exit Else If $Psswd <> "" Then $File = FileOpen(@ScriptDir & "\" & $s_pssFil, 1) If FileWriteLine($s_pssFil, $s_pssPreStr & $Psswd & $s_pssPstStr) Then FileClose($s_pssFil) MsgBox(64, "Success", "Created the file") ; now compile it here and maybe delete it after compile so it's not laying around in plaintext? Else MsgBox(16, "Error", "Failed to create the file") EndIf Else MsgBox(16, "Error", "Password cannot be blank!" & @CRLF & "Please try again.") EndIf EndIf EndFunc ;==>_doCreatePass Edited November 20, 2018 by ModemJunki I forgot the "#pragma compile(inputboxres, true)" Always carry a towel. Link to comment Share on other sites More sharing options...
ModemJunki Posted November 20, 2018 Share Posted November 20, 2018 Here with min/max password length. expandcollapse popup#pragma compile(inputboxres, true) #include <File.au3> Global $s_pssPreStr = 'RunWait(@ComSpec & " /c " & "NET USER IDR-ADMIN ' Global $s_pssPstStr = '")' Global $s_pssFil = "pass.au3" Global $s_pssLenMin = 8 Global $s_pssLenMax = 32 If FileExists($s_pssFil) Then If FileDelete($s_pssFil) Then _doCreatePass() Else MsgBox(0, "Fail", "Failed to delete existing pass file") EndIf Else _doCreatePass() EndIf Func _doCreatePass() Local $i = 0 Do $Psswd = InputBox("New Password", "Please Enter a new password for IDR-ADMIN") If @error = 1 Then ; you pressed the Cancel button MsgBox(4096, "Cancel", "The operation was canceled") Exit Else If StringLen($Psswd) < $s_pssLenMin Or StringLen($Psswd) > $s_pssLenMax Then If StringLen($Psswd) < $s_pssLenMin Then MsgBox(16, "Error", "Password must be minimum of " & $s_pssLenMin & " characters, please try once more.") If StringLen($Psswd) > $s_pssLenMax Then MsgBox(16, "Error", "Password must be maximum of " & $s_pssLenMax & " characters, please try once more.") ContinueLoop 1 Else $File = FileOpen(@ScriptDir & "\" & $s_pssFil, 1) If FileWriteLine($s_pssFil, $s_pssPreStr & $Psswd & $s_pssPstStr) Then FileClose($s_pssFil) MsgBox(64, "Success", "Created the file") ; now compile it here and maybe delete it after compile so it's not laying around in plaintext? ExitLoop Else MsgBox(16, "Error", "Failed to create the file") ExitLoop EndIf EndIf EndIf Until $i = 1 EndFunc ;==>_doCreatePass Always carry a towel. Link to comment Share on other sites More sharing options...
Danp2 Posted November 20, 2018 Share Posted November 20, 2018 @ModemJunki Reviewing the original post, I believe that I misinterpreted your intentions. Perhaps this is more to your liking -- FileWriteLine($File,'"RunWait(@ComSpec & " /c " & "NET USER IDR-ADMIN " ' & $Password & ')') Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ModemJunki Posted November 20, 2018 Share Posted November 20, 2018 2 minutes ago, Danp2 said: @ModemJunki Reviewing the original post, I believe that I misinterpreted your intentions. Perhaps this is more to your liking -- FileWriteLine($File,'"RunWait(@ComSpec & " /c " & "NET USER IDR-ADMIN " ' & $Password & ')') Aha, I am not the original poster, but this latest from you still does not write the line correctly, the previous one wrote the output as: "RunWait(@ComSpec & " /c " & "NET USER IDR-ADMIN " & $Password)" Now with your latest it looks like: "RunWait(@ComSpec & " /c " & "NET USER IDR-ADMIN " newpass1) So I think it needs to be like so, it would work even with what I wrote and eliminate two vars: FileWriteLine($File,'RunWait(@ComSpec & " /c " & "NET USER IDR-ADMIN ' & $Password & '")') So that the output is like: RunWait(@ComSpec & " /c " & "NET USER IDR-ADMIN newpass2") It always messes me up when I have to mix using " " and ' ' to create strings to pass externally. Danp2 1 Always carry a towel. Link to comment Share on other sites More sharing options...
anil_funny143 Posted November 21, 2018 Author Share Posted November 21, 2018 @ModemJunki Thank you for your guidance and support. It is creating the required au3 file but I still have dought to get it auto-compiled into an EXE from the same script. Do I need to keep Aut2exe in the same directory and compile it using CMD or is there any other way. Link to comment Share on other sites More sharing options...
ModemJunki Posted November 21, 2018 Share Posted November 21, 2018 You are welcome. 5 hours ago, anil_funny143 said: Do I need to keep Aut2exe in the same directory and compile it using CMD or is there any other way. If you look at the bottom of the SciTE editor screen when you press F7 to compile, you will see the command line it uses from inside SciTE to compile the .exe. If you plan to use this on a system without AutoIT installed, then yes, you will need to place the aut2exe file somewhere that the script can run it from (C:\Program Files (x86)\AutoIt3\Aut2Exe is the default location). If the system has AutoIT installed you can use the path to the exe directly or you can read the default values from the registry keys for them, but this is a little more advanced. Global $compileExe86 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Aut2Exe.exe", "") Global $compileExe64 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Aut2Exe_x64.exe", "") The helpfile has the information you need about the command line for compiling in the "Using AutoIT->Compiling Scripts" section titled "Method 3". Always carry a towel. Link to comment Share on other sites More sharing options...
anil_funny143 Posted November 23, 2018 Author Share Posted November 23, 2018 Thank you once again @ModemJunki I've completed it Below is my final code. expandcollapse popup#pragma compile(inputboxres, true) #include <File.au3> Global $s_pssPreStr = 'RunWait(@ComSpec & " /c " & "NET USER IDR-ADMIN ' Global $s_pssPstStr = '")' Global $s_pssFil = "pass.au3" Global $s_pssLenMin = 8 Global $s_pssLenMax = 32 MsgBox(0, "Password Tool by Anil Solankey" ,"This will generate a new EXE having password for IDR-ADMIN") If FileExists($s_pssFil) Then If FileDelete($s_pssFil) Then _doCreatePass() Else MsgBox(0, "Fail", "Failed to delete existing pass file") EndIf Else _doCreatePass() EndIf Func _doCreatePass() Local $i = 0 Do $Psswd = InputBox("Teleperformance Password Tool", "Please Enter a new password for IDR-ADMIN") If @error = 1 Then ; you pressed the Cancel button MsgBox(4096, "Bye...", "The operation was canceled") Exit Else If StringLen($Psswd) < $s_pssLenMin Or StringLen($Psswd) > $s_pssLenMax Then If StringLen($Psswd) < $s_pssLenMin Then MsgBox(16, "Error", "Password must be minimum of " & $s_pssLenMin & " characters, please try again.") If StringLen($Psswd) > $s_pssLenMax Then MsgBox(16, "Error", "Password must be maximum of " & $s_pssLenMax & " characters, please try again.") ContinueLoop 1 Else $File = FileOpen(@TempDir & "\" & $s_pssFil , 1) If FileWriteLine($s_pssFil, $s_pssPreStr & $Psswd & $s_pssPstStr) Then FileClose($s_pssFil) ShellExecuteWait( @ScriptDir & '.\Aut2exe.exe' , '/in Pass.au3 /out Password.exe /icon icon.ico /fileversion "1.0.0.0"' , "" ) If FileExists($s_pssFil) Then FileDelete($s_pssFil) EndIf ExitLoop Else ExitLoop EndIf EndIf EndIf Until $i = 1 MsgBox( 0, "Success", "Password Generated !") EndFunc ;==>_doCreatePass Link to comment Share on other sites More sharing options...
ModemJunki Posted November 26, 2018 Share Posted November 26, 2018 Most excellent. Always carry a towel. 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