Windows Thread, deleting mapped drives in .vbs that are mapped with .bat in Technical; Hi,
Im new here...
We have moved our scripts to .vbs as we were running .bat log ons, so now ...
-
7th December 2005, 08:13 PM #1 deleting mapped drives in .vbs that are mapped with .bat
Hi,
Im new here...
We have moved our scripts to .vbs as we were running .bat log ons, so now when the scripts run, we get this drive is already in use. The only way to get rid of this is to delete the local profile on the computer, but with over 1000 clients we dont want to do that so..... is there any way that we can put in the first part of the vbscript a script that will automatically delete these mapped drives that are stored on the local computer???
This is what is running now... and we get the error this drive is already in use
Const Pupils = "cn=pupils"
set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))
If InStr(strGroups,pupils) Then
wshNetwork.MapNetworkDrive "p:","\\hades\upublic"
wshNetwork.MapNetworkDrive "s:","\\hades\business"
wshNetwork.MapNetworkDrive "v:","\\hades\uapps"
End If
ive aslo got this
These are supposed to delete the drives, but it doesnt work...
Sub DeleteDriveMapping(s"p:")
' This will remove the mapped drive sDriveLetter
CreateObject("WScript.Shell").Run "net.exe use " _ & sDriveLetter & " /delete", 0, True
WScript.Sleep 250
End Sub
or
Option Explicit
Dim objShell, objNetwork, DriveLetter1
DriveLetter1 = "P:"
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
objnetwork.removenetworkdrive DriveLetter1
wscript.quit
Any ideas???
Cheers
Tim
-
-
IDG Tech News
-
7th December 2005, 08:43 PM #2 Re: deleting mapped drives in .vbs that are mapped with .bat
you need to enumerate all the network drives and then iterate through and delete them.
I don't know if this is correct but give it a bash...
Code:
Set objNetwork = WScript.CreateObject("WScript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
For i = 0 to colDrives.Count-1 Step 2
objNetwork.RemoveNetworkDrive colDrives.Item(i)
Next Hope it works - more info at http://www.microsoft.com/technet/scr..._wsh_peht.mspx
-
-
7th December 2005, 08:58 PM #3 Re: deleting mapped drives in .vbs that are mapped with .bat
thanks for the reply....
Ive looked at the microsoft site and used this one
Set objNetwork = WScript.CreateObject("Wscript.Network")
objNetwork.RemoveNetworkDrive "G:"
now, it says it has disconnected the drive, but since the drive has been mapped on the local computer with the .bat logon using the command net use l: "....." it is still present and when i double click on the so called disconnected drive it connects again.
Does the scirpt in green above delete the local profile of the user and then creates it again, thats what im looking to do
Tim
-
-
7th December 2005, 09:03 PM #4 Re: deleting mapped drives in .vbs that are mapped with .bat
If you want to delete local profiles then you need Delprof
-
-
7th December 2005, 09:09 PM #5 Re: deleting mapped drives in .vbs that are mapped with .bat
to delete the local profile simply add the following line to a startup batch file:
or in VBScript try...
Code:
Set objShell = Wscript.CreateObject("Wscript.Shell")
CMDLine = "delprof /q /i"
objShell.Run CMDLine check out http://www.microsoft.com/technet/scr..._wsh_pkoy.mspx
-
SHARE:
Similar Threads
-
By timbo343 in forum Windows
Replies: 11
Last Post: 2nd April 2012, 09:06 AM
-
By Grommit in forum Windows
Replies: 12
Last Post: 28th January 2008, 04:15 PM
-
By proby1 in forum Windows Vista
Replies: 2
Last Post: 15th November 2007, 11:39 AM
-
By marco84 in forum Educational Software
Replies: 11
Last Post: 8th June 2007, 11:21 AM
-
Replies: 5
Last Post: 26th January 2007, 12:22 AM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules