Sha256: 8056f058849c06f8d706b0b8bbe1328c6a3d38c99b4ab1f11358ba215e9e86ac

Contents?: true

Size: 988 Bytes

Versions: 151

Compression:

Stored size: 988 Bytes

Contents

module VMC::Micro::Switcher

  class Windows < Base
    def version?
      VMC::Micro.run_command("cmd", "/c ver").to_s.scan(/\d+\.\d+/).first.to_f
    end

    def adminrun(command, args=nil)
      if version? > 5.2
        require 'win32ole'
        shell = WIN32OLE.new("Shell.Application")
        shell.ShellExecute(command, args, nil, "runas", 0)
      else
        # on older version this will try to run the command, and if you don't have
        # admin privilges it will tell you so and exit
        VMC::Micro.run_command(command, args)
      end
    end

    # TODO better method to figure out the interface name is to get the NAT ip and find the
    # interface with the correct subnet
    def set_nameserver(domain, ip)
      adminrun("netsh", "interface ip set dns \"VMware Network Adapter VMnet8\" static #{ip}")
    end

    def unset_nameserver(domain, ip)
      adminrun("netsh", "interface ip set dns \"VMware Network Adapter VMnet8\" static none")
    end
  end

end

Version data entries

151 entries across 151 versions & 9 rubygems

Version Path
af-0.3.22 lib/vmc/micro/switcher/windows.rb
af-0.3.20 lib/vmc/micro/switcher/windows.rb
af-0.3.19 lib/vmc/micro/switcher/windows.rb
udn-0.3.23.5 lib/vmc/micro/switcher/windows.rb
udn-0.3.23.4 lib/vmc/micro/switcher/windows.rb
udn-0.3.23.3 lib/vmc/micro/switcher/windows.rb
af-0.3.19.beta.1 lib/vmc/micro/switcher/windows.rb
udn-0.3.23.2 lib/vmc/micro/switcher/windows.rb
udn-0.3.23.1 lib/vmc/micro/switcher/windows.rb
udn-0.3.23.0.pre lib/vmc/micro/switcher/windows.rb
af-0.3.18.12 lib/vmc/micro/switcher/windows.rb
olympe-0.4 lib/vmc/micro/switcher/windows.rb
sys-0.3 lib/vmc/micro/switcher/windows.rb
olympe-0.3 lib/vmc/micro/switcher/windows.rb
olympe-0.2 lib/vmc/micro/switcher/windows.rb
olympe-0.1 lib/vmc/micro/switcher/windows.rb
sys-0.2 lib/vmc/micro/switcher/windows.rb
sys-0.1 lib/vmc/micro/switcher/windows.rb
as-1.0 lib/vmc/micro/switcher/windows.rb
as-0.3.18.11 lib/vmc/micro/switcher/windows.rb