Sha256: 5c32906eb4cfa57cc5715c37b1ebe600b368425ff00093618dd0ebb0a143eafb

Contents?: true

Size: 977 Bytes

Versions: 77

Compression:

Stored size: 977 Bytes

Contents

module CFMicro::Switcher

  class Windows < Base
    def version
      CFMicro.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
        CFMicro.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

77 entries across 77 versions & 3 rubygems

Version Path
cf-4.1.5.rc2 lib/micro/switcher/windows.rb
cf-4.1.5.rc1 lib/micro/switcher/windows.rb
cf-4.1.4 lib/micro/switcher/windows.rb
cf-4.1.4.rc2 lib/micro/switcher/windows.rb
cf-4.1.4.rc1 lib/micro/switcher/windows.rb
cf-4.1.3 lib/micro/switcher/windows.rb
cf-4.1.2.rc2 lib/micro/switcher/windows.rb
cf-4.1.2.rc1 lib/micro/switcher/windows.rb
cf-4.1.1 lib/micro/switcher/windows.rb
cf-4.1.0rc2 lib/micro/switcher/windows.rb
cf-4.1.0rc1 lib/micro/switcher/windows.rb
micro-cf-plugin-1.0.0 lib/micro-cf-plugin/micro/switcher/windows.rb
micro-cf-plugin-0.1.1.rc1 lib/micro-cf-plugin/micro/switcher/windows.rb
micro-cf-plugin-0.1.0 lib/micro-cf-plugin/micro/switcher/windows.rb
micro-cf-plugin-0.1.0.rc3 lib/micro-cf-plugin/micro/switcher/windows.rb
micro-cf-plugin-0.1.0.rc2 lib/micro-cf-plugin/micro/switcher/windows.rb
micro-cf-plugin-0.1.0.rc1 lib/micro-cf-plugin/micro/switcher/windows.rb