PC Review


Reply
Thread Tools Rate Thread

detecting a mapped drive (server) and replacing it

 
 
Fred
Guest
Posts: n/a
 
      30th Jun 2003
Hello folks,

We are in the process of changing the servers that many of our users
currently have mapped drives to file shares...Is there anyway to have a
login script (or any other script for that matter) detect the server name of
the mapped resource and re-map that drive to another server? Is there anyway
to do this by group name? Or someway through an Ou?

Thanks in advance for the help!





 
Reply With Quote
 
 
 
 
Bart Denison[MSFT]
Guest
Posts: n/a
 
      3rd Jul 2003
You could do something like this this in a .vbs script and run it under
cscript:

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oNET = CreateObject("WScript.Network")
Set oNetDrives = oNET.EnumNetworkDrives
For i=0 to oNetDrives.Count -1 step 2
if oNetDrives.Item(i)="" then
' This removes network connections not attached to a drive
letter
oNet.RemoveNetworkDrive oNetDrives.Item(i+1), TRUE, TRUE
else
' This removes network conenctions that ARE mapped to a drive
letter
oNET.RemoveNetworkDrive oNetDrives.Item(i), TRUE, TRUE
end if
Next

NewDriveLetter = ""
'
' Iterate drives to find an available letter
' Skip A, B, and C since A & B are traditioanlly floppy, and C is the
boot drive
'
For I = ASC("D") to ASC("Z") step 1
If not oFSO.DriveExists(CHR(I)) then
NewDriveLetter = Chr(I) & ":"
Exit For
End If
Next
oNET.MapNetworkDrive NewDriveLetter, UNCPath, ,[UserName], [Password]
If not oFSO.DriveExists(NewDriveLetter) then
ErrorMsg = "Error - unable to map drive to " & NewDriveLetter & "to "
& TestShare
ErrorMsg = ErrorMsg & " using specified credentials. Please enter
valid credentials"
WScript.Echo ErrorMsg
End If

It's not necessarily the cleanest code, but it iterates existing
connections, deltes them, and then finds the next available drive eltter and
connects some server and share to that drive letter.



"Fred" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hello folks,
>
> We are in the process of changing the servers that many of our users
> currently have mapped drives to file shares...Is there anyway to have a
> login script (or any other script for that matter) detect the server name

of
> the mapped resource and re-map that drive to another server? Is there

anyway
> to do this by group name? Or someway through an Ou?
>
> Thanks in advance for the help!
>
>
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
server name rather than mapped drive ftrujill0 Microsoft Access Macros 1 26th Feb 2008 12:02 AM
Mapped Server Drive Password Charles M Microsoft Windows 2000 Netware 0 7th Sep 2004 11:32 PM
mapped drive available to a server application David Microsoft Windows 2000 0 5th Apr 2004 05:36 PM
Replacing The Server's C Drive Me Microsoft Windows 2000 Networking 10 15th Aug 2003 04:41 AM
Re: 2000 server not detecting hard drive on install Björn Johansson Microsoft Windows 2000 Setup 0 4th Aug 2003 03:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:25 PM.