i am new to Power Shell scripting.
Need one help on finding out if this is possible
start-process calling an .exe file created in .Net application , the statement looks like this
$procss_name= start-process -filepath " FilePath\code.exe" -passthru
the code.exe file generates a popup with a 'OK' button with no title but having context "Report Generated"
can we close the popup using script or aviod the popup to show.
It is the code.exe that is throwing this popup, not PoSH. Unless code.exe provides a way to ignore the popup, you are going to have to code for it.
For example, see this tool / module and determine if you can leverage it.
Thanks for the reply.
Just wanted to confirm, one thing by this we can confirm that we cannot handle the popup from the application.?
can't we try to find(using script) for any popup generated and using the 'Sendkeys' can we send and enter key or such
As far as confirmation is concerned, you'll have two choices.
Talk to the vendor / dev of code.exe to see what they provide
or write code to look for code.exe process, and window handles and then write code to address that Window handle.
No, you cannot write code to catch any random popup. You have to know explicitly what you are looking for and what you can / cannot interact with.
PoSH is not a UI controller. That is what WASP, and things like AutoIt or are for. You can do it, it's more of an art than a science.
Sendkeys are a funny thing and I do use them in several cases. So, you can use them, but they have issues, based on different host OS, cpu speeds, screen refresh rates, etc., so, timing can cause SendKeys to just fail.
The tool I pointed you to allows the use of Sendkeys.
With Wasp, you just do this...
Get-Command -Module wasp | ft name
Name ---- Get-WindowPosition Remove-Window Select-ChildWindow Select-Control Select-Window Send-Click Send-Keys Set-WindowActive Set-WindowPosition
ProcessName : notepad ProcessId : 2164 IsActive : False Handle : 29034340 Title : Untitled - Notepad Class : Notepad
So, you are still going o have to code for whatever your target is.
Find the process - this is the easy part
Enumerate Windows and grab the one you need, this can be a bit challenging depending on what the target is and how you can attach to it., because you have to get the main Windows, then potentially any child window.
Use the app authors api to interact with it or Wasp or AutoIT or write you own.
I have examples of a SendKeys effort, calling / finding a notepad process and interacting with it. Whether you can do this with code.exe model / dialogs is a different matter. Again, the is not elegant , the Wasp if far superior to doing this on your own. Especially, if you've never done this or seen it done.
Thanks for the elaborate explaining.
I tried all the ways except the third party, but came to a conclusion on observing the script.
I was trying to get the WindowHandle pre and post the stat-Process, no use as this start-process is running as background process and also once this is called that post steps are executing only once the popup is shown.
AS you suggested , i was trying to get it fixed from the Code of the .exe file.