Sha256: e0ffdeb20ca731ddd4c18498888f917e5743879d38a035268f669e5a8527cb9f

Contents?: true

Size: 729 Bytes

Versions: 1

Compression:

Stored size: 729 Bytes

Contents

# function to check whether machine is currently shutting down
function ShuttingDown {
    [string]$sourceCode = @"
using System;
using System.Runtime.InteropServices;

namespace VagrantWindows {
    public static class RemoteManager {
        private const int SM_SHUTTINGDOWN = 0x2000;

        [DllImport("User32.dll", CharSet = CharSet.Unicode)]
        private static extern int GetSystemMetrics(int Index);

        public static bool Shutdown() {
            return (0 != GetSystemMetrics(SM_SHUTTINGDOWN));
        }
    }
}
"@
    $type = Add-Type -TypeDefinition $sourceCode -PassThru
    return $type::Shutdown()
}

if (ShuttingDown) {
  Write-Host "Shutting Down"
  exit 1
}
else {
  Write-Host "All good"
  exit 0
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-windows-1.3.0.pre.1 lib/vagrant-windows/scripts/reboot_detect.ps1