Sha256: ef4fc672cdaf6570fea23d791399bcbe6b040458a271de11d1b9fc22f27eda99

Contents?: true

Size: 1000 Bytes

Versions: 25

Compression:

Stored size: 1000 Bytes

Contents

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

namespace Vagrant {
    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) {
  exit 1
} else {
  # See if a reboot is scheduled in the future by trying to schedule a reboot
  . shutdown.exe -f -r -t 60

  if ($LASTEXITCODE -eq 1190) {
    # reboot is already pending
    exit 2
  }

  # Remove the pending reboot we just created above
  if ($LASTEXITCODE -eq 0) {
    . shutdown.exe -a
  }
}

# no reboot in progress or scheduled
exit 0

Version data entries

25 entries across 22 versions & 5 rubygems

Version Path
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-unbundled-2.0.0.1 plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-unbundled-1.9.8.1 plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-unbundled-1.9.7.1 plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-unbundled-1.9.5.1 plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-unbundled-1.9.1.1 plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-unbundled-1.8.5.2 plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-unbundled-1.8.5.1 plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-unbundled-1.8.4.2 plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-unbundled-1.8.4.1 plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-unbundled-1.8.1.2 plugins/guests/windows/scripts/reboot_detect.ps1
vagrant-unbundled-1.8.1.1 plugins/guests/windows/scripts/reboot_detect.ps1