timbo343 Posted December 7, 2005 Posted December 7, 2005 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
Ric_ Posted December 7, 2005 Posted December 7, 2005 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... 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/scriptcenter/guide/sas_wsh_peht.mspx
timbo343 Posted December 7, 2005 Author Posted December 7, 2005 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
ChrisH Posted December 7, 2005 Posted December 7, 2005 If you want to delete local profiles then you need Delprof
Ric_ Posted December 7, 2005 Posted December 7, 2005 to delete the local profile simply add the following line to a startup batch file: delprof /q /i or in VBScript try... Set objShell = Wscript.CreateObject("Wscript.Shell") CMDLine = "delprof /q /i" objShell.Run CMDLine check out http://www.microsoft.com/technet/scriptcenter/guide/sas_wsh_pkoy.mspx
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now