![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Windows NT/2000/2003 Server/2008 Server Find support for Windows NT/2000/2003 Server/2008 Server editions. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 4
OS: Windows 2003 Server
|
[SOLVED] vbs login script
Hey, I don't have much experience with vbs so I'm looking for a bit of help!
This is the script that I'm currently running: -------- ON ERROR RESUME NEXT DIM objNetwork,colDrives,i SET objNetwork = CREATEOBJECT("Wscript.Network") SET colDrives = objNetwork.EnumNetworkDrives FOR i = 0 to colDrives.Count-1 Step 2 ' Force Removal of network drive and remove from user profile ' objNetwork.RemoveNetworkDrive strName, [bForce], [bUpdateProfile] objNetwork.RemoveNetworkDrive colDrives.Item(i),TRUE,TRUE NEXT Set objNetwork = CreateObject("WScript.Network") objNetwork.MapNetworkDrive "G:" , "\\servername\sharename1" objNetwork.MapNetworkDrive "S:" , "\\servername\sharename2" objNetwork.MapNetworkDrive "T:" , "\\servername\sharename3" --------- Currently this script removes all network drives, then maps g,s and t.I want to change this script so that it overrides existing drives with the same letter (g,s,t) but leaves all other drives that the client may have mapped themselves intact. (ex. usershare to a different server). Any help would be greatly appreciated. Thanks, Chris |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
TSF Enthusiast
Join Date: Mar 2009
Location: Portland, OR
Posts: 821
OS: MS-Dos 6.22 - Win7
|
Re: vbs login script
This should do it:
Code:
ON ERROR RESUME NEXT
DIM objNetwork
SET objNetwork = CREATEOBJECT("Wscript.Network")
' objNetwork.RemoveNetworkDrive strName, [bForce], [bUpdateProfile]
objNetwork.RemoveNetworkDrive "G:",TRUE,TRUE
objNetwork.RemoveNetworkDrive "S:",TRUE,TRUE
objNetwork.RemoveNetworkDrive "T:",TRUE,TRUE
objNetwork.MapNetworkDrive "G:" , "\\servername\sharename1"
objNetwork.MapNetworkDrive "S:" , "\\servername\sharename2"
objNetwork.MapNetworkDrive "T:" , "\\servername\sharename3"
Jerry
__________________
Microsoft MVP - Windows Desktop Experience Of course I know all the answers; I just don't always match the answers to the right questions. Rated R for Violence -- When your PC flies through a window, that's violent, right? |
|
|
|
|
|
#3 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 4
OS: Windows 2003 Server
|
Re: vbs login script
Thanks for the reply Jerry.
This script seems like it would work, but if i have T mapped to t:\servername\d and run this script it wont remove the existing map and remap it to \\servername\sharename3 If no mapping initially existing for T, then it works great and maps t to \\servername\sharename3 like it should. It doesn't seem to want to remove existing drive mappings. Hope that makes sense. Chris Last edited by asmoa; 05-22-2009 at 11:08 AM. |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 4
OS: Windows 2003 Server
|
Re: vbs login script
I ended up getting it to work by adding "wscript.sleep 300"
-------------------- ON ERROR RESUME NEXT DIM objNetwork SET objNetwork = CREATEOBJECT("Wscript.Network") ' objNetwork.RemoveNetworkDrive strName, [bForce], [bUpdateProfile] objNetwork.RemoveNetworkDrive "G:",TRUE,TRUE objNetwork.RemoveNetworkDrive "S:",TRUE,TRUE objNetwork.RemoveNetworkDrive "T:",TRUE,TRUE wscript.sleep 300 objNetwork.MapNetworkDrive "G:" , "\\servername\sharename1" objNetwork.MapNetworkDrive "S:" , "\\servername\sharename2" objNetwork.MapNetworkDrive "T:" , "\\servername\sharename3" --------------------- |
|
|
|
|
|
#5 (permalink) |
|
TSF Enthusiast
Join Date: Mar 2009
Location: Portland, OR
Posts: 821
OS: MS-Dos 6.22 - Win7
|
Re: vbs login script
Glad you figured it out. I tested by only removing one mapped drive so didn't run into the need for a delay to let the system catch up. I should have thought of that.
If your issue is resolved you can mark this thread Solved using the Thread Tools at the top of the thread on the right side. Jerry
__________________
Microsoft MVP - Windows Desktop Experience Of course I know all the answers; I just don't always match the answers to the right questions. Rated R for Violence -- When your PC flies through a window, that's violent, right? |
|
|
|
![]() |
| Thread Tools | |
|
|