[python-win32] Changing a drive letter (original) (raw)
Mike Driscoll mdriscoll at co.marshall.ia.us
Fri Jan 25 16:05:24 CET 2008
- Previous message: [python-win32] Changing a drive letter
- Next message: [python-win32] Embedding/bundling Python, best practices?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Roger,
Message: 5 Date: Thu, 24 Jan 2008 17:04:33 -0500 From: "Roger Upole" <rwupole at msn.com> Subject: [python-win32] Re: Changing a drive letter To: <python-win32 at python.org> Message-ID: <BAYC1-PASMTP011ABE75732CFCA97BC8DEA3380 at CEZ.ICE> Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Mike Driscoll wrote: > Hi, > > In a login script I helped write, we have some code that maps drives > based on what department or group the user belongs to. One of our > groups has users that use USB devices that will occasionally be > plugged in before they log in. This causes the map drive part of the > script to fail at mapping one of the drives if the USB device grabs that drive letter first. > > Here's how we map a drive: > > from win32netcon import RESOURCETYPEDISK as DISK > win32wnet.WNetAddConnection2(DISK, mapping[0], mapping[1]) > > > And here's the diskpart line: > > subprocess.call(r'diskpart /s \%s\someFolder\changeg.txt' % pdcName) > > where the text file contains the following two lines: > > > select volume G: > assign letter=T > > > Any ideas or tips would be appreciated. Thanks! You can use functions in win32file to remap a drive letter. import win32file v=win32file.GetVolumeNameForVolumeMountPoint('x:\') win32file.DeleteVolumeMountPoint('x:\') win32file.SetVolumeMountPoint('t:\',v) Roger
This sounds pretty cool. I'll give it go and see if it works better than what I am already doing. Thanks!
Mike
- Previous message: [python-win32] Changing a drive letter
- Next message: [python-win32] Embedding/bundling Python, best practices?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]