Hi All, Thank you for reading. Im trying to create a power shell script that installs some exes. i have got it work to the point were it Runs Ninite. but once this finishes it hangs until the user clicks close. could any one help me with a command line to wait for ninites to finish then closes. <pre> # This starts the office install which doesnt need to be a part of the other command $p = New-Object System.Diagnostics.Process $pinfo = New-Object System.Diagnostics.ProcessStartInfo("C:\Install_File\Office.exe",""); $p.StartInfo = $pinfo; $p.Start(); $p.WaitForExit(); Write-Host "end of ps1" + (Get-Date).DateTime # This starts Ninite and waits for it to be closed to carry on the script $p = New-Object System.Diagnostics.Process $pinfo = New-Object System.Diagnostics.ProcessStartInfo("C:\Install_File\Ninite.exe",""); $p.StartInfo = $pinfo; $p.Start(); $p.WaitForExit(); Write-Host "end of ps1" + (Get-Date).DateTime # This deletes all the files # Remove-Item c:\Ninite.exe # Remove-Item c:\Office.exe Remove-Item C:\Install_File -Recurse </pre>
There is: Code: Start-Process <pathtoexe>\<nameofFiletorun> -wait which runs the file and waits until that program finishes, then carries on to the next powershell line. remove the -wait and powershell runs it and goes onto the next command without waiting. Im not a PS coder so only know basics. Very similar to the batch START /Wait way which i use a lot.
Hi thank you for the reply I have tried this and fails. The command line I have works but at the end of the it running it does not close causing the script to freeze. I think there is two options 1. When the program is idle it gets closed 2.click option to click close But the problem is i have looked every were for help but have no idea. I beleave it can be done but believe I need some one more experience and I'm a beginner
Powershell is not my area of expertise, but maybe it has something to do with ninite free versus ninite pro? https://ninite.com/help/features/silent.html Also, don't most programs designed to run in a CMD shell return a completion code of some kind? Is there a way to know this and wait for the code? These are just some thoughts. Hopefully, they'll help.
Hi all Thank you for all your help i found a fix will a little coding added by me There software out there called AutoIT a person made a scripted that would run ninites but kept asking me to add the ninite exe. as i was looking for somthink to run at the begin of a fresh install this was not any good for me. After looking round i found that i could adapt this person script to do what i needed. So the finished script is Code: ; Tell the script to run the program Run("Ninite.exe", "", @SW_SHOWMAXIMIZED) ; Blocks any Mouse use BlockInput(1) ; Moves the mouse to a selected location MouseMove(0, 0) WinMove(WinWait("Preparing"), "", @DesktopWidth + 5, @DesktopHeight + 5) While 1 WinSetTrans ( "Preparing", "", 255 ) WinSetTrans ( "Ninite", "", 255 ) $text = WinGetText("Ninite", "") If StringInStr($text, "Finished.",1) Then ExitLoop EndIf Sleep(500) WEnd ; Wait for 1 Seconds. Sleep(1000) ControlClick("Ninite", "", "[ID:2]") ; Enables mouse use BlockInput(0) it will run Ninites at this point it will block user input (mouse will not work) once it finishes it will select close and carry on. Please note that this will only work if UAC is off or and for preset up (as it get installed before a user is created) Ninite-Silent.exe Ninite-Silent.au3 (use this to change thinks to your liking and create new Ninite-silent.exe Ninite.exe (download new from there website and change the name to this and will work the same Spoiler: Download https://drive.google.com/drive/folders/0B7BcRyjtLORVLUN3bkF1LUpqR2s?usp=sharing USE AT OWN RISK IT WORKS FOR ME BUT IM NOT A PROGRAMMER