+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
Windows Thread, scrips to change drive letters in Technical; I'm after a script to run from the server to change a group of computer drive letters. so I want ...
  1. #1
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,093
    Thank Post
    457
    Thanked 150 Times in 95 Posts
    Rep Power
    71

    scrips to change drive letters

    I'm after a script to run from the server to change a group of computer drive letters.

    so I want to move drives 'E' and 'F' to 'Y' and 'Z'

    Server is server 2008
    workstations are XP Pro SP3

    any help suggestions much appreciated

    Cheers

    Kev

  2. #2
    bio
    bio is offline
    bio's Avatar
    Join Date
    Apr 2008
    Location
    netherlands
    Posts
    520
    Thank Post
    16
    Thanked 130 Times in 102 Posts
    Rep Power
    37
    found this to get you started

    Code:
    ' Change the Drive Letter of a Volume
    
    
    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 = "Q:"
        objVolume.Put_
    Next
    bio..

  3. Thanks to bio from:

    PEO (12th January 2010)

  4. #3
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,093
    Thank Post
    457
    Thanked 150 Times in 95 Posts
    Rep Power
    71
    I have no idea what it means lol

  5. #4

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,680
    Thank Post
    3,210
    Thanked 1,030 Times in 955 Posts
    Rep Power
    361
    Quote Originally Posted by PEO View Post
    I'm after a script to run from the server to change a group of computer drive letters.

    so I want to move drives 'E' and 'F' to 'Y' and 'Z'

    Server is server 2008
    workstations are XP Pro SP3

    any help suggestions much appreciated

    Cheers

    Kev
    Are you using logon / startup scripts to assign or map the drives in the first place ? If so then you can make the ammendments in those scripts ?

    Generally those scripts are in the sysvol area afaik - could be wrong

    If not and you are using group policy then am guessing you can use group policy to specify what drive letters you want mapping to each network share / mapping ?

  6. Thanks to mac_shinobi from:

    PEO (12th January 2010)

  7. #5

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,680
    Thank Post
    3,210
    Thanked 1,030 Times in 955 Posts
    Rep Power
    361
    Quote Originally Posted by PEO View Post
    I have no idea what it means lol
    It's a vbscript that uses wmi and the win32_Volume class to change drive letters of a specific partition / drive

  8. Thanks to mac_shinobi from:

    PEO (12th January 2010)

  9. #6
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,093
    Thank Post
    457
    Thanked 150 Times in 95 Posts
    Rep Power
    71
    yes we have startup scripts for logon.


    thats in a bat file

    'Logon batch file to map any drives and change security group memberships
    net use r: /d
    net use t: /d
    net use k: /d
    net use r: \\W8E-DC01\Apps$
    net use t: "\\W8E-DC01\Central Resource Library"
    net use k: \\dfe4105dc2\mis
    net localgroup Administrators MYSCHOOL\Technicians /add

  10. #7
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,093
    Thank Post
    457
    Thanked 150 Times in 95 Posts
    Rep Power
    71
    Quote Originally Posted by bio View Post
    found this to get you started

    Code:
    ' Change the Drive Letter of a Volume
    
    
    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 = "Q:"
        objVolume.Put_
    Next
    bio..
    Ok I tested that on my machine and it works, but is it possible to edit it so it does two drive letters rather than just on?


    edit.... my machine in windows 7 ultimate
    Last edited by PEO; 12th January 2010 at 04:01 PM.

  11. #8

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,680
    Thank Post
    3,210
    Thanked 1,030 Times in 955 Posts
    Rep Power
    361
    Quote Originally Posted by PEO View Post
    yes we have startup scripts for logon.


    thats in a bat file

    'Logon batch file to map any drives and change security group memberships
    net use r: /d
    net use t: /d
    net use k: /d
    net use r: \\W8E-DC01\Apps$
    net use t: "\\W8E-DC01\Central Resource Library"
    net use k: \\dfe4105dc2\mis
    net localgroup Administrators MYSCHOOL\Technicians /add
    Instead of using the other vbscript can't you just change the letters in the original script so it changes the letters there ie


    Code:
    net use r: /d
    net use t: /d
    net use k: /d
    net use A: \\W8E-DC01\Apps$
    net use B: "\\W8E-DC01\Central Resource Library"
    net use C: \\dfe4105dc2\mis
    net localgroup Administrators MYSCHOOL\Technicians /add
    where A, B and C are the drive letters you want

  12. Thanks to mac_shinobi from:

    PEO (12th January 2010)

  13. #9
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,093
    Thank Post
    457
    Thanked 150 Times in 95 Posts
    Rep Power
    71
    sorry I should have said, the drive letters I wish to change are virtual cd/dvd drives

  14. #10
    Quackers's Avatar
    Join Date
    Jan 2006
    Posts
    1,309
    Thank Post
    40
    Thanked 141 Times in 116 Posts
    Rep Power
    53
    I do not recommend using Z: as i'm sure its used by the system at netlogon for scripts, and so could cause an issue.

    Edit, found this from MS "By default, Windows XP assigns mapped network drives to the highest available drive letter, starting with drive Z, to avoid drive letter collisions."
    Last edited by Quackers; 12th January 2010 at 03:45 PM.

  15. Thanks to Quackers from:

    PEO (12th January 2010)

  16. #11
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,093
    Thank Post
    457
    Thanked 150 Times in 95 Posts
    Rep Power
    71
    script dosent work on xp

  17. #12
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,093
    Thank Post
    457
    Thanked 150 Times in 95 Posts
    Rep Power
    71
    Cheers Quackers, you learn something new everyday I didnt know that

  18. #13
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,093
    Thank Post
    457
    Thanked 150 Times in 95 Posts
    Rep Power
    71
    screen shot of error message on a machine running Windows xp pro sp3
    Attached Images Attached Images

  19. #14

    Join Date
    Nov 2009
    Posts
    79
    Thank Post
    3
    Thanked 4 Times in 4 Posts
    Rep Power
    10
    That script only works for mapped drives i believe your virtual ones will be done via software i think

  20. #15
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,093
    Thank Post
    457
    Thanked 150 Times in 95 Posts
    Rep Power
    71
    before I created the image for the machine I changed the drive letters but sysprep put them back to the begining. I'm a little stuck here as I dont fancy changing them, machine by machine everytime I depoly an image.

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Remapping USB drive letters in Citrix
    By cookie_monster in forum Thin Client and Virtual Machines
    Replies: 4
    Last Post: 26th September 2008, 12:05 PM
  2. Sysprep & Drive Letters
    By jack0w in forum Windows
    Replies: 26
    Last Post: 16th September 2008, 07:24 PM
  3. Replies: 3
    Last Post: 25th October 2007, 09:14 AM
  4. Replies: 4
    Last Post: 9th October 2006, 10:00 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •