# windowslib # # Tells Hyper-V to set the state to stopped. This script by itself cannot kill # a running Windows Phone emulator. It doesn't have the permissions to do so. # You should use "taskkill" to kill the "xde.exe" process which will cause the # emulator to close, but Hyper-V won't register that the emulator is stopped. # Run this script to let Hyper-V know you just killed the emulator. # # Copyright (c) 2014-2017 by Appcelerator, Inc. All Rights Reserved. # Licensed under the terms of the Apache Public License # Please see the LICENSE included with this distribution for details. if ($args.count -eq 0) { echo '{"success": false, "message": "No Windows Phone emulator name specified"}' exit 1 } $query = "Select * from MSVM_Computersystem where Description like '%Virtual%'" + " AND ElementName like '" + $args[0] + ".%' AND ProcessID >= 0 AND enabledState != 3" $vm = Get-WmiObject -computername localhost -NameSpace root\Virtualization\v2 -query $query if ($vm.__CLASS -eq 'Msvm_ComputerSystem') { if ((Get-CimInstance Win32_OperatingSystem).Version -ge (new-object 'Version' 10,0)) { $foo = Stop-VM -Name $vm.ElementName -TurnOff } else { $foo = $vm.RequestStateChange(3) } echo '{"success": true}' } else { echo '{"success": true, "message": "Not found or not running"}' }