Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


script to change drive letter

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,30133
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> script to change drive letter
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 script to change drive letter - 1/20/2006 4:27:34 AM   
  humtake

 

Posts: 1
Score: 0
Joined: 1/20/2006
Status: offline
right now, we are having to manually change the dvd drive letter from d to z on every computer we build.  im trying to add a little vscript file into the batch file so it automatically will change the drive letter.

so far, i was able to find this:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colVolumes = objWMIService.ExecQuery _
("Select * from Win32_Volume Where Name = 'D:\\'")

for each objVolume in colVolumes
objVolume.DriveLetter = "Z:"
objVolume.Put_
Next

and, i tested this on a machine that is not on our domain and has windows server 2003, and it works flawlessly.  however, when i try to run this on computers that are newly imaged, this script does not work.  i keep getting an error saying:

script:  drive.vbs
line:  8
char:  1
error:  0x80041010
code:  80041010
source:  (null)

does anyone know why this wont work?  im thinking it has something to do with sysprep or maybe another function of an enterprise software, since it works on my personal computer that is not on the domain. 

any help will be appreciated.
 
 
Post #: 1
 
 RE: script to change drive letter - 1/20/2006 4:49:21 AM   
  DiGiTAL.SkReAM


Posts: 1152
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: online
We use diskpart.exe to do this.

I know that a lot of people rely on WMI for a lot of things, but I have always foudn it to be slow and unreliable.


_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to humtake)
 
 
Post #: 2
 
 RE: script to change drive letter - 1/20/2006 5:50:56 AM   
  didorno

 

Posts: 361
Score: 0
Joined: 2/12/2005
From:
Status: offline
humtake, my info is that the system support for this code is rather limited. Follow DiGiTAL.SkReAM's advice.


Supported Platforms
Windows Server 2003
Yes
Windows XP
No
Windows 2000
No
Windows NT 4.0
No
Windows 98
No
 


_____________________________

Regular Expression ? I (L+o{1,}v{1,3}e\s)+[iI]t!$

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> script to change drive letter Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts