I'm trying to find a method to launch a background process in Powershell. At first I tried using Start-Job and then realized that that launches the job in a new session. My end goal is to create a while loop that runs every hour (already have that code worked out) but I can't find a way to launch it in a background process that once the session closes the process with stop as well. Any help will be greatly appreciated.
Related
I have recorded a Bluestacks macro to perform menial tasks in the ZDay : Hearts for heros game. However, because there are so many unpredictable popups in the application I would like the macro to start the app, run the menial activity I recorded and then exit the application.
The application doesn't have a specific way to exit (file/exit doesn't exist) except on the phone is to force it closed using the OS. Is there a command I can put at the beginning of the macro to start the application and another to close the application at the end of the macro?
Bluestacks has controls that allow perform a generic exit command. So, I didn't need to know how to exit the program from inside the application. I just used the built in functionality to accomplish what I need.
I've experienced under various setups that MATLAB stops responding when you try to open a file during script execution. Usually I'd just promptly kill MATLAB and start whatever I was doing before. However, now I'm working on a remote machine with a buggy OS interface that basically won't let me kill MATLAB. As the whole MATALB interface doesn't respond, I can't CTRL+C.
Is this a known issue and is there a workaround?
I wrote an extremely lengthy script that creates a form. The main purpose of it it to connect to vCenter servers, total up hosts/vms within different datacenters and also identify ESXi host versions. Running the script in ISE the form loads fine and when I click the Button to start the many various functions to update the fields, it runs. I have Foreach() fields throughout and added in a little StatusLabel to the bottom of the form to show me where in the script it is currently scanning.
Once all was done and working, I saved the PS1 file and moved it to a shared server to be run. When I run the Powershell console (as Admin) and point to the file, the Form loads ok. Once I click the button to begin generating the info, It just changes to (Not Responding) and grays out. I know it's working and if left there long enough it will return the info.
Why does the console window not function like the ISE? I want to be able to see the information and Status Label update/change as it goes through the script (just like I do in the ISE).
Appreciate the feedback. The script is several thousand lines long and would need to be scrubbed before I upload. Was hoping to just get some general info before doing that.
I updated to v4 and verified that my command window was running as STA using the command from Jan Chrbolka. Script runs properly now.
I was also facing the same issue.(Btw, I cannot upgrade Powershell to V4 right now since it is my company owned one.)
The Browse button that I incorporated in my form was not working when I am lauching it from Powershell command line. It went to Not Responding state when I click the browse button.
I took the advise from Jan ChrbolkaMay about the STA and MTA.
I checked for the threads related to that and changed the script execution format to the below one which fixed my issue.(adding the word -STA)
powershell -STA -File D:\PS\GUI.ps1
For checking the current state. Use the below query in Commandshell as well as ISE.
I was wondering if i could get AHK-script to automatically launch a program in the background when i start another.
Example:
Execute C:\any.exe.
AHK launches: C:\monitor.exe
When any.exe is closed, ahk should kill monitor.exe
Awsome if you guys could help me.
Edit: Note that i am a complete newcomer to programming or scripting in every way you can think of
Check out timer in the autohotkey docs.
You could set a timer that checks every 5 seconds to run winexist to test for the existence of c:\any.exe - and when it returns true then your code could run c:\monitor.exe
Now that your code knows that c:\any.exe is running, your code could launch a second timer that checks for when its process is closed (check out process in the ahk docs). When it is closed, then use winkill to close the c:\monitor.exe process.
So, look up these commands:
winexist
timer
process
Hey I have a scheduled task going which basically laucnhes a .aspx page with IE Explorer, i know theres better ways of doing this i.e console apps etc but im stuck with this for the moment.
So the scheduled task runs fine and launches the ie and the page and the script on the onload on that page runs fine to. But the IE window stays open and the tasks remains as "Running". Preventing it from running the next time its due to run.
How can I get the scheduled tasks to stop "running" and maybe even close that IE windows cheers!
If you're looking to just make a HTTP request to the page, instead of opening a browser window, (get Firefox, okay?), you could launch curl http://server/path/to/script.aspx which is a command-line app, which makes the request and then quits immediately after.
For this, you'll need to download curl from http://curl.haxx.se/latest.cgi?curl=win32-ssl