Roger,

> 
> Message: 5
> Date: Thu, 24 Jan 2008 17:04:33 -0500
> From: "Roger Upole" <[EMAIL PROTECTED]>
> Subject: [python-win32]  Re: Changing a drive letter
> To: <python-win32@python.org>
> Message-ID: <[EMAIL PROTECTED]>
> 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 RESOURCETYPE_DISK as DISK 
> > win32wnet.WNetAddConnection2(DISK, mapping[0], mapping[1])
> >
> >
> > And here's the diskpart line:
> >
> > subprocess.call(r'diskpart /s \\%s\someFolder\change_g.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



_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to