User Tools

Site Tools


microsoft:scripting:vbscript:scripts:wmi-setopticaldriveletter-remote

Version 1

'WMI-SetOpticalDriveLetter-Remote.vbs
'For moving the optical drive of a remote machine.
'Contains code from http://www.visualbasicscript.com/tm.aspx?high=&m=30133&mpage=1.
'20110510, v1.
 
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
 
strComputer = "10.1.1.1"
strAcc = "administrator"
strPassword = "password"
 
Set objWMIService = objLocator.ConnectServer ( strComputer, "\root\cimv2", strComputer & "\" & strAcc, strPassword )
objWMIService.Security_.impersonationlevel = 3
 
'Select all volumes of type compact disc.
'http://msdn.microsoft.com/en-us/library/aa394515(v=VS.85).aspx - Win32_Volume Class.
Set colVolumes = objWMIService.ExecQuery ("SELECT * FROM Win32_Volume WHERE DriveType = 5")
 
For Each vol in colVolumes
 
	If vol.DriveLetter = "E:" Then
 
		vol.DriveLetter = "X:"
		vol.Put_
 
	End If
 
Next
 
Set colVolumes = Nothing
Set objWMIService = Nothing
Set objLocator = Nothing
microsoft/scripting/vbscript/scripts/wmi-setopticaldriveletter-remote.txt · Last modified: 2011/05/10 17:30 by bas

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki