Reminder to halt VM?


I have a Linux VM on a Windows 10 host. I only use it when working on my PHPStorm projects, which is not an everyday thing. Sometimes I close PHPStorm, go on to working on unrelated tasks, and completely forget about my VM. Not only is that a waste of memory when I'm not using it, but if I shut down Windows I risk breaking the VM - that hasn't happened yet, but... (I know the idea of vagrant and provisioners is that it's no big deal to recreate a VM, but not all my customizations are in the provisioning files, due to my lack of knowledge of how to do that.)

So, is there a way in PHPStorm to attach something to the close event (I don't care if it's closing of the software overall or a project) to either halt the VM or remind me that it's still running?


Hi there,

I personally do not know such solution.

Anyway, some tickets to watch after:


P.S. The only thing that comes into my mind right now: have some batch/PowerShell script that will be launched by scheduler (e.g. every 5 mins or so) that will check if there is any PhpStorm process running .. and if not -- attempt to shutdown the VM. Nuance: do not launch actual shutdown code if VM is not running.

Downside is obvious: what if you just restarting IDE .. or temporarily close it etc -- no way to read your mind/intentions.

(just in case: startup tasks are already possible.)


Thanks. Yeah, those tickets are applicable, and I just now voted for them.

That scheduled script sounds like a reasonable idea. I don't need it to actually do the shutdown - it would be sufficient to just alert me that PhpStorm is not running but the VM is. But that sounds like pretty advanced scripting - if it were Linux I might have a hope of figuring out how to write a little cron-run bash script, but Windows under-the-hood stuff is pretty opaque to me. Maybe someday...


PowerShell script would be the best solution here. It's not super hard .. but yes, you would need to spend a bit of time to get into the syntax (as it's differs / unusual at first glance).

General idea is:

  • Enumerate running processes looking for PhpStorm.exe or PhpStorm64.exe (may require elevated permissions for that, not sure)
  • If found -- make up some marker (e.g. temp file with unique name -- could be in user's Temp folder or whatnot). That's enough to act as a marker (we do not care what PID PhpStorm uses etc)
  • If not found: see if marker does exist. If exist (which means IDE was recently closed): delete it and show the required notification.

Some links:


P.S. Instead of enumerating running processes you may just look up at what "C:\Users\USERNAME\.PhpStorm2018.1\config\port.lock" file is (the file size). If it's 0 bytes -- IDE is not running; otherwise -- it's running. NOTE: if IDE process is killed in any way (actual kill; crash; hard reboot/power loss) the file most likely still be non-zero length.


  • No need for process enumeration (so no potential need for admin rights)


  • Still need to remember the state from past run (to avoid false alarms)
  • Path is IDE-version specific
  • If you are using more than one IDE version at a time (e.g. stable and next major EAP builds) you would need to perform such checks in more than one place.

Please sign in to leave a comment.