Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

Disconecting Mapped drives

Hi

I have ADS on Win2k3 and for the AD users Iwrote a script to map the network drive and disconnect when logoff.. but the disconnect doesn't work, it says the drive is already in use.

Mapping Script between the lines
-----------------------------------------------------------------
Option Explicit
Dim objNetwork
Dim strDriveLetter, strRemotePath, strUserName
strDriveLetter = "Z:"
strRemotePath = "\\ARCMAIL\ARC"
Set objNetwork = WScript.CreateObject("WScript.Network")
strUserName = objNetwork.UserName
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath _
& "\" & strUserName
WScript.Quit
-----------------------------------------------------------------------

Disconect scripts: between the lines
------------------------------------------------------------------
Option Explicit
Dim objNetwork, strDriveLetter
strDriveLetter = "Z:"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.RemoveNetworkDrive strDriveLetter
Wscript.Quit
-----------------------------------------------------------------

ZAK
0
ZAK360
Asked:
ZAK360
  • 3
  • 2
  • 2
  • +1
1 Solution
 
BasheerptCommented:
Why dont use NET USE command with group policy? more flexible i believe.
NET USE X: \\server\sharedFolder  (To connect)
NET USE X: \\Server\sharedFolder /DELETE (To disconnect)

Use it in a batch file and put it in the login/logoff sections of the Group policy.

Rgds

0
 
ZAK360Author Commented:
When i try to use NET USE manually
NET USE X: \\servername\Shared Folder
System error 67 has occurred.
The network name cannot be found.

If i use NET USE X: \\server fqdn name\Shared Folder
It comes up with
System error 1326 has occurred.
Logon failure: unknown user name or bad password.

ZAK
0
 
dom_adminCommented:
Does your shared folder contain spaces ?

If the net use command does not work, that is what you should find a solution for - 'cause it should be working :-) And when it doesn't, it is a sign of another problem.

/Brian
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
dom_adminCommented:
Are you using a Domain ? Or is this a logon in a "Workgroup" environment ?

If you are using a Domain, does the client user logon to the domain ? Or with a local account ?

/Brian
0
 
ZAK360Author Commented:
Logon to the domain.. the user is logging on to the domain not local. There is no workgroup.

-- ZAK
0
 
dom_adminCommented:
Did your share contain spaces ?
0
 
StuFox100Commented:
use the following command:

net use z: /delete

Should fix you up.
Cheers
Stu
0
 
StuFox100Commented:
Also to make your script work try making this change:

objNetwork.RemoveNetworkDrive strDriveLetter
to
objNetwork.RemoveNetworkDrive strDriveLetter,true

Cheers
Stu
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now