MelvinChan Posted July 23, 2018 Posted July 23, 2018 Hi all. I'm still a beginner in programming & even more so in "Autoit". But I find it interesting & I need some simple automation task being done. So far, I've seen some videos on "Autoit" & well, I've been led by the hand until I come to this as shown below. The "#-----------------------------------------------" I just put on here, it's not part of the program. But I put it to segregate only to show the program. My aim here is I tried to get an installer be it *.msi or *.exe from a specific location as shown. And then simulate once the software is opened to click on some buttons & choose. Then once finished it will close. Do advise on how I should continue with this. I've tried to break down, bit by bit, it seems like it's OK, there's no major error but just cannot seem to run, do advise, thanks. Any intelligent comments & assistance will be useful, thanks. #----------------------------------------------- Main() Func Main() Initialize(); AskUser(); DoInstall(); CleanUp(); EndFunc ; End:main() Func Initialize() $InstNSCPDest = ("C:\Users\kchan5\Desktop\OP5WA" & "\NSCP-0.5.0.65-x64.msi") $NSCPSetup = ("NSClient++ (x64) Setup") FileInstall("NSCP-0.5.0.65-x64.msi", $InstNSCPDest,1) EndFunc ; End:Initialize() Func AskUser() EndFunc ; End:AskUser() Func DoInstall() Run($InstNSCPDest) sleep(2000); ProcessWaitClose("msiexec.exe") WinActivate($NSCPSetup) WinWaitActive($NSCPSetup) Send("{ENTER}") sleep(2000); Send("{TAB}") sleep(2000); Send("{ENTER}") sleep(2000); Send("{TAB}") sleep(1000); Send("{TAB}") sleep(1000); Send("{ENTER}") sleep(2000); Send("{sgcorpop5p01}"); sleep(2000); Send("{ENTER}") sleep(2000); #Send("{ENTER}") EndFunc ; End:DoInstall() Func CleanUp(); EndFunc ; End:CleanUp(); #-----------------------------------------------
spudw2k Posted July 23, 2018 Posted July 23, 2018 Firstly, welcome. Secondly, One thing I see is you are calling ProcessWaitClose. I just want to make sure you are using it the way you think it should be. Are you expecting the msiexec.exe process to close before the rest of the installation wizard is automated? I'm not at a place where I can test this to see, but I suspect msiexec should remain running until the install is complete. Perhaps ProcessWait is more appropriate? Thirdly, doing sleeps for the timing can be tricky as not every machine may behave the same way. Also, sending keystrokes my become problematic as other process/applications could interefere if they take focus. You should look into ControlCLick functions and using the AUInfo tool included with the AutoIt installer. Search the forum for usages or come back with questions/difficulties. Lastly, most installers support a silent installation which would eliminate the need to automate the installation wizard. If this installer is NSClient++ (what came up on a google), it looks like it will support silent install and various deployment customization tweeks. Have a look here (https://docs.nsclient.org/installing/). I always prefer to do a silent install versus automating a GUI if I can, but if not the Control... Functions should provide more stable/elegant automation means versus keystrokes and mouse clicks. Good luck, have fun and come back when/if you get stuck. 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
MelvinChan Posted July 23, 2018 Author Posted July 23, 2018 Well, yes, thanks for replying. I appreciate it. And I got your pointers & I'll take note of it. But the thing is now I haven't gotten the programe to work yet. So yes I need to visually see it before I put it to run in the back away from the users, etc. Although I'm still considered "new" to programing languages, powershell, etc, I still know a thing or to with VBscript, so I've got the techniques (some what) & understand the logic (but lack the writing experience & commands to call the thing to work) & is very determine to get something good out of my perseverance to automate some mundane things I'll push forward to it & take any good workable advise. I know nothing is impossible, just need other's advise, thanks.
MelvinChan Posted July 23, 2018 Author Posted July 23, 2018 I also understand from after reading so many what others wrote about "msiexec.exe" needs to be run only because I'm trying to run a "*.msi" file, if it's an *.exe file I don't need to call up this "msiexec.exe" file. So correct me if I'm wrong on that. Thanks. I've already been trying for like 4-5 days on "ShellExecuteWait", "ShellExecute" "ProcessWait", "Run" just to name a few of combination testings but nothing seems to execute & run that file. I did managed to get it to run on my home's desktop, but it was for x86 (32bit) version, when at company it's a 64bit version, which shouldn't be an issue. The timing part once I can get it to run & get in, I'll be able to catch the timing more appropriately, I just need the initiation to START first, then I'll test & see how it can work for my environment. Thanks.
Earthshine Posted July 23, 2018 Posted July 23, 2018 (edited) silent install the msi show your code if you want help Edited July 23, 2018 by Earthshine My resources are limited. You must ask the right questions
Moderators JLogan3o13 Posted July 23, 2018 Moderators Posted July 23, 2018 Moved to the appropriate forum. Moderation Team "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Earthshine Posted July 23, 2018 Posted July 23, 2018 (edited) Here is a good example of how to do silent install with msi, specifying properites if needed msiexec /i c:\path\to\package.msi /quiet /qn /norestart /log c:\path\to\install.log PROPERTY1=value1 PROPERTY2=value2 You probably just want msiexec /i c:\path\to\package.msi /quiet /qn /norestart /log c:\path\to\install.log These examples are from just general examples and Command Line examples. If you post your code we can help you further. Also, you may not want to do the norestart thing, if not, leave it out of there. We will need to convert these to AutoIt with your data. Th Edited July 23, 2018 by Earthshine My resources are limited. You must ask the right questions
MelvinChan Posted August 1, 2018 Author Posted August 1, 2018 I've already put up my "old script" earlier, but maybe when this post is moved then the new people reading it cannot see it. Anyway, I've already modified it & set the objects & functions to global then it ran correctly as it should as shown. So how do I add in the installation quietly & in the background? And non-restart, but can this restart function be a need to use function if I want to then I allow it to restart? Can you help me use a "#" to remark it out? Like default it's non-restart, if I need to I'll choose the function to restart by itself. Thanks. And I saw that your advise is to have a log file after installation, which is good to have. But how do I add into my existing working script? Appreciate if you can assist me to add it into my current working script, thanks. #----------------------------------------------- Main() Func Main() Initialize(); AskUser(); DoInstall(); CleanUp(); EndFunc ; End:main() Func Initialize() Global $InstNSCPDest = "C:\temp\OP5WA\NSCP-0.5.0.65-x64.msi" Global $NSCPSetup = "NSClient++ (x64) Setup" FileInstall("NSCP-0.5.0.65-x64.msi", $InstNSCPDest,1) EndFunc ; End:Initialize() Func AskUser() EndFunc ; End:AskUser() Func DoInstall() ShellExecute($InstNSCPDest) sleep(2500); WinActivate($NSCPSetup) WinWaitActive($NSCPSetup) Send("{ENTER}") sleep(1100); Send("{down}") sleep(1100); Send("{ENTER}") sleep(1100); Send("{TAB}") sleep(900); Send("{TAB}") sleep(900); Send("{ENTER}") sleep(1000); Send("{ENTER}") sleep(1100); Send("sgcorpop5p01"); sleep(1000); Send("{ENTER}") sleep(1100); Send("{ENTER}") sleep(10000); Send("{ENTER}") EndFunc ; End:DoInstall() Func CleanUp(); EndFunc ; End:CleanUp();
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