Windows 10: Hyper-V Windows 10 Batch file to start/stop VM on command

  1.    27 Mar 2016 #1

    Hyper-V Windows 10 Batch file to start/stop VM on command


    I am running Hyper-V on Windows 10.

    I am using the PC for media playback / gaming in big screen and rarely see the desktop. I have an service running and APP on my phone, so i can start batch files and programs without the need for a KB/M.

    I have just setup a VM, but i dont want it running all the time, i just want to use it to do some video rendering or whatever when i need it to, i especially don't want it to be running when playing games.

    so is there a way i could write a batch file or VBS to start the VM (not connect) then i could connect to VM via remote desktop on my laptop (or other machine)

    and another batch file to turn it off, when i want to do some gaming?

    i have googled for about an hour but came up empty
      My ComputerSystem Spec


  2. Posts : 11,234
    Windows 10 Pro
       28 Mar 2016 #2

    The script shown in this video does exactly that:

      My ComputerSystem Spec

  3.    28 Mar 2016 #3

    When you make Kari's powershell script put this
    Code:
    Stop-Process -processname powershell
    as the last line, and powershell will exit when you close the Virtual Machine window!
      My ComputerSystem Spec


  4. Posts : 11,234
    Windows 10 Pro
       29 Mar 2016 #4

    flybynite said: View Post
    When you make Kari's powershell script put this
    Code:
    Stop-Process -processname powershell
    as the last line, and powershell will exit when you close the Virtual Machine window!
    Totally unnecessary.

    The video shows two ways to launch the PowerShell script, a normal shortcut and a bit more "elegant" VB script. Both ways will terminate the PowerShell process as soon as the user has closed vm window and the script has shut down the vm.

    If any additional commands would have been needed, I had added them in my instructions.
    Last edited by Kari; 29 Mar 2016 at 02:21. Reason: Typos
      My ComputerSystem Spec


 

Related Threads
Solved Start a program from a batch file in Software and Apps
4 Apps of mine run a batch file that -tries- to call/start and EXE program. These Batch files need to work with OS XP thru Win 10. Win 10 has a pop-up window asking user if its okay to run/execute my EXE. No other Win version does this and thus I...
Batch file hide command window in General Support
I have a batch command to back up a subdirectory: xcopy "C:\All\*" "E:\Allback\*" /E /Q How can I hide the command window during the execution?
Start a program from a batch file in Software and Apps
I'm trying to create a batch file that should - call another batch file - start a program and then wait for the program to close - call another batch file My goal with this is to work around an issue in Windows 10 where the screensaver won't...
I've been trying to figure this out for a while now and I can't. I've looked at tons of small tips online to get this working but it doesn't work at all. I have a batch file which causes various programs to start when opened. However, one of them...
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 01:24.
Find Us