Map Drive Script - Check for Drive letter in use
-
Group Policy is great for setting so many things - and @Mike-Davis is trying to get me to use GP to set more this way.
Yet I"m 'old school' in using a batch and the net use command to map drives. And there has been one or two cases where he and I have worked on the GPO and had it not work, but the batch does.
Enter the case of computers with Media Bays. I recall years ago the thought of not setting any Share Drive Resource lower than the M: drive. Media Bay eat up several letters with this of course which is why you may not want to set anything lower than M:.
However we have a client that uses F: (shared) and H: (Personal Home) both. Is there a statement (If / Then) in batch commands that could see if the F: is used then set to (x): drive?
Off to look and try to remember my old batch command line settings - I only ask this while I also search...
-
-
@Danp said in Map Drive Script - Check for Drive letter in use:
http://stackoverflow.com/questions/27246899/batch-check-if-mapped-network-drive-exists
Thanks - That points in the right direction I want to go.
However I just ran into a wall with it. Disk Management reports the drives (E;F;G;H) as being assigned. However Windows Explorer does not. Therefore, the
if exist f: net use n: \\unc\share
I had planned to use won't work.
-
@gjacobse said in Map Drive Script - Check for Drive letter in use:
@Danp said in Map Drive Script - Check for Drive letter in use:
http://stackoverflow.com/questions/27246899/batch-check-if-mapped-network-drive-exists
Thanks - That points in the right direction I want to go.
However I just ran into a wall with it. Disk Management reports the drives (E;F;G;H) as being assigned. However Windows Explorer does not. Therefore, the
if exist f: net use n: \\unc\share
I had planned to use won't work.
Wouldn't this result in the shares being double connected to, but as a new letter each time?
Why not just disconnect the share with
objNetwork.RemoveNetworkDrive "M:", TRUE, TRUE
And then let the script remap the drive to the original letter?
-
@DustinB3403 said in Map Drive Script - Check for Drive letter in use:
@gjacobse said in Map Drive Script - Check for Drive letter in use:
@Danp said in Map Drive Script - Check for Drive letter in use:
http://stackoverflow.com/questions/27246899/batch-check-if-mapped-network-drive-exists
Thanks - That points in the right direction I want to go.
However I just ran into a wall with it. Disk Management reports the drives (E;F;G;H) as being assigned. However Windows Explorer does not. Therefore, the
if exist f: net use n: \\unc\share
I had planned to use won't work.
Wouldn't this result in the shares being double connected to, but as a new letter each time?
Why not just disconnect the share with
objNetwork.RemoveNetworkDrive "M:", TRUE, TRUE
And then let the script remap the drive to the original letter?
I don't think it would double map. If the drive does exist, then map it as N, otherwise it would / could map as F.
-
@gjacobse said in Map Drive Script - Check for Drive letter in use:
@DustinB3403 said in Map Drive Script - Check for Drive letter in use:
@gjacobse said in Map Drive Script - Check for Drive letter in use:
@Danp said in Map Drive Script - Check for Drive letter in use:
http://stackoverflow.com/questions/27246899/batch-check-if-mapped-network-drive-exists
Thanks - That points in the right direction I want to go.
However I just ran into a wall with it. Disk Management reports the drives (E;F;G;H) as being assigned. However Windows Explorer does not. Therefore, the
if exist f: net use n: \\unc\share
I had planned to use won't work.
Wouldn't this result in the shares being double connected to, but as a new letter each time?
Why not just disconnect the share with
objNetwork.RemoveNetworkDrive "M:", TRUE, TRUE
And then let the script remap the drive to the original letter?
I don't think it would double map. If the drive does exist, then map it as N, otherwise it would / could map as F.
Not as in double like that but to explain
M: is mapped to datashare1
login request hits
M: exists ok, go map the datashare1 as N: now. -
I think the first M: would be an empty sd card reader or something similar
It exists, so the network share would be mapped to N:Least that is what I imagined he wants to do.
-
@DustinB3403 said in Map Drive Script - Check for Drive letter in use:
@gjacobse said in Map Drive Script - Check for Drive letter in use:
@DustinB3403 said in Map Drive Script - Check for Drive letter in use:
@gjacobse said in Map Drive Script - Check for Drive letter in use:
@Danp said in Map Drive Script - Check for Drive letter in use:
http://stackoverflow.com/questions/27246899/batch-check-if-mapped-network-drive-exists
Thanks - That points in the right direction I want to go.
However I just ran into a wall with it. Disk Management reports the drives (E;F;G;H) as being assigned. However Windows Explorer does not. Therefore, the
if exist f: net use n: \\unc\share
I had planned to use won't work.
Wouldn't this result in the shares being double connected to, but as a new letter each time?
Why not just disconnect the share with
objNetwork.RemoveNetworkDrive "M:", TRUE, TRUE
And then let the script remap the drive to the original letter?
I don't think it would double map. If the drive does exist, then map it as N, otherwise it would / could map as F.
Not as in double like that but to explain
M: is mapped to datashare1
login request hits
M: exists ok, go map the datashare1 as N: now.Right, however in this case it would be
F: = CompactFlash drive
F: exist, map datashare as N: -
@momurda said in Map Drive Script - Check for Drive letter in use:
I think the first M: would be an empty sd card reader or something similar
It exists, so the network share would be mapped to N:Least that is what I imagined he wants to do.
Exactly
-
So is the goal here to just always map the share and not care about the drive letter?
-
@DustinB3403 said in Map Drive Script - Check for Drive letter in use:
So is the goal here to just always map the share and not care about the drive letter?
Preferably not. But in some cases, you have to adjust the company standard until the standard is changed. If you have a standard of:
F: = \\unc\shared H: = \\unc\home
Since E-H are the Media bay, they can't be used as the company standard, so, new script for those (few) computers with media bays to move the SHARED and HOME drives to available lettes.
-
Is the compact flash drive or other empty media card drives ever going to be used?
Some of the computers here have them, but ill be damned if I have ever seen one in use. We do use portable usb with CF or SD slots in them, but the ones built into the case are never used I think.If the situation is the same wher eyou are, I think you could delete them if they exist (if exist m: net use m: //delete) then map the network drive normally. Or you can use GP to replace/update drive letters
-
@momurda said in Map Drive Script - Check for Drive letter in use:
Is the compact flash drive or other empty media card drives ever going to be used?
Some of the computers here have them, but ill be damned if I have ever seen one in use. We do use portable usb with CF or SD slots in them, but the ones built into the case are never used I think.If the situation is the same wher eyou are, I think you could delete them if they exist (if exist m: net use m: //delete) then map the network drive normally. Or you can use GP to replace/update drive letters
You could delete them if they 'existed'. Windows Explorer does not list them. But Disk Management does.
One option mentioned was to disconnect them if not to be used... problem solved.
-
@gjacobse
Yea you could just unplug the usb header on the mobo. -
@momurda said in Map Drive Script - Check for Drive letter in use:
@gjacobse
Yea you could just unplug the usb header on the mobo.This or find the powershell script and object names that allow you to find remove the drive letter mapping.
-
All of this seems like a lot of hard word versus (with management approval) an email stating -
Starting tomorrow, what used to be the F: drive will now be mapped as the P: drive and what was the H: will now be the R: drive.
Please be aware that any scripts currently using the F: or H: mappings will need to be updated to the new location. Instead of using P: or R:, please use \servername\sharename1 for P: and \servername2\sharename2 for R: This will prevent you from having to update these scripts in the future in the event that these drive letters will need to change.-IT.
-
@Dashrender I agree, yet still don't understand the reason for using drive letters in the local drive space that is normally accessed by windows when connecting local storage.
Start from Z and go backwards for any shares.
-
-
@DustinB3403 said in Map Drive Script - Check for Drive letter in use:
@Dashrender I agree, yet still don't understand the reason for using drive letters in the local drive space that is normally accessed by windows when connecting local storage.
Start from Z and go backwards for any shares.
It's not greenfield, I'm sure Gene is working from a setup someone else built 15+ years ago before PCs came with all those stupid memory card slots that suck up a letter but don't map into explorer like he mentions.
-
@Dashrender said in Map Drive Script - Check for Drive letter in use:
@DustinB3403 said in Map Drive Script - Check for Drive letter in use:
@Dashrender I agree, yet still don't understand the reason for using drive letters in the local drive space that is normally accessed by windows when connecting local storage.
Start from Z and go backwards for any shares.
It's not greenfield, I'm sure Gene is working from a setup someone else built 15+ years ago before PCs came with all those stupid memory card slots that suck up a letter but don't map into explorer like he mentions.
I'm sure it was setup longer then 15 years ago sadly.