Solved

DOS commands  to open & close a network share

Posted on 2014-02-18
12
572 Views
Last Modified: 2014-03-24
A handful of my users are experiencing a problem when they login. Their home folder is mapped to a network share (U: drive). Unfortunately, it seems that when the user logs on the system brings the drive up as disconnected. This causes problems with applications that need to write to this U: drive as it believes the U: drive is disconnected. If I have the user open their U: drive and run the application again the system recognizes it as connected and the application works.

I'm looking for DOS commands that I can add to their respective logon script that will open up their home folder (the U: drive) and then close it. If this can be transparent to the user that is great as well.
0
Comment
Question by:dowhatyoudo22
  • 4
  • 3
  • 3
  • +1
12 Comments
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39867771
You can start an explorer with a parameter, like this:

explorer u:\

This will open a standard windows explorer with the (mapped) U: drive
0
 
LVL 26

Assisted Solution

by:pony10us
pony10us earned 166 total points
ID: 39867777
Are you sure the drive is disconnected as soon as the login script runs or after a period of time like say 15 minutes?

Couple of suggestions:

1. You could try doing a directory listing right after mapping

     dir u: > NULL  

This will send the output of the directory to NULL so that it doesn't show up. If the U: drive contains a lot it could slow down the login script.

2. You could open and close the folder as you ask but I am not sure how transparent it would be and there may be some potential for issues.  

    REM Open U: drive    
    explorer u:    

    REM Close most recent explorer window
    TASKKILL /IM EXPLORER.EXE

Option 2 should only close the most recently opened explorer.exe task which should be the U: drive
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39867783
You could also force a disconnect and connect, like this:

net use u: /d /y
net use u: \\<server>\<share
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39867895
Could it be you need to use a group policy in there to "wait for the network" etc.   is this being mapped in the login script, or hung over from before?  Can't give you link at the moment from here but if you google "wait for network" policy should get it.

Steve
0
 

Author Comment

by:dowhatyoudo22
ID: 39868005
Performing the directory listing after creating the mapping sounded like a good idea up until you mentioned the size of the user's home directory and it slowing down logins. Some of my users have a couple of GB in the home directory.

I tried the "explorer U:"  which works but when I try to run the "taskkiller /im explorer.exe" command it gets confused. Sometimes it closes the window that was just opened. Other times it presents a screen preparing to shutdown the entire machine.

The disconnect & reconnect might do it. Looking into the issue further it appears that some of my users has mapped drives that pointed directly to the server where the home directory was located. One of my engineers before he left was working on changing these pointers to a DFS server. It appears that I may have a conflict with these user's current/previous mapping to thier home directory and this login script attempting to creating the new mapping.
0
 
LVL 26

Expert Comment

by:pony10us
ID: 39868026
As long as the root of their U: drive is small (they keep their files in separate folders right?) then the directory feature would work. However we all know that that never happens.  

The problem with the other method that I mentioned is that it will attempt to close the most recently opened explorer window so if the previous command does not function then it will close the root explorer which is the system.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 37

Assisted Solution

by:Gerwin Jansen
Gerwin Jansen earned 167 total points
ID: 39868454
After the disconnect/connect, you could add a basic dir command that lists a 'non existing' file, instead of listing the whole directory (which could take some time).

Like this:

net use u: /d /y
net use u: \\<server>\<share
dir u:\*.ybx

(ybx is an extension not likely to find, choose another if you like)
0
 
LVL 26

Expert Comment

by:pony10us
ID: 39868480
Good idea looking for something that you know won't exist.  I would still send the output to NULL since you don't really care about the response.

dir u:\*.ybx > NULL
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39868495
>> I tried the "explorer U:"  which works but when I try to run the "taskkiller /im explorer.exe" command it gets confused.

This is true, I tried and saw same behaviour. The explorer is started as a separate task and the kill will just kill any explorer it will find. You can select the 'right' explorer by searching for the window title but again it takes some time for the explorer process to 'appear'.

You could try this:
(in a batch file, otherwise use single % instead of double ones)

@echo off
:: Open explorer
explorer U:\
:: Wait 3 seconds
@ping -n 1 -w 3000 1.1.1.1 >nul:
:: kill the window with title U:\
FOR /F "tokens=2" %%a IN ('tasklist /fi "windowtitle eq U:\\" ^| findstr explorer') DO taskkill /pid %%a

Open in new window

0
 

Author Comment

by:dowhatyoudo22
ID: 39887176
Think the issue is tied to a concflict in GPOs and login scripts. User's mapped drive in question is configured one way. But GPOs and login scripts are attempting to map them another. This appears to be causing some sort of conflict and the drive is coming up disconnected.
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 167 total points
ID: 39887296
Well, manually disconnect all drives in one of the users machines - net use * /delete from command prompt or disconnect them in explorer.

Then do a

gpresult /scope user  /h user.html
start user.html

or

gpresult /scope user /v > gp.txt
start gp.txt

and look for any scripts or group policy preferences issues re: drive mappings.

Also check the user's home drive and login script properties in their user object in AD.

And also if you search on SYSVOL for *.cmd, *.bat, *.vbs are likely to be any script locations, e.g.

dir \\domain.local\sysvol\*.cmd *.bat *.vbs /s /b > scripts.txt
start scripts.txt

And take a look at those for drive mappings.

Also as suggested earlier make sure your logins aere waiting for the network to become active before logging in, i.e. check that this policy has been set in AD GPO:

Computer Configuration\Administrative Templates\System\Logon\
"Always wait for the network at computer startup and logon"

Steve
0
 

Author Comment

by:dowhatyoudo22
ID: 39950551
Deleting/removing the mapped drive in question manually and then having the user log off and then back in allowing group policy to take affect appears to be my best option at this point. The pool of affected users is unknow but to small to start removing/deleting mapped drives to user in particular OUs.

Thanks everyone!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now