Solved

Logon and Shutdown Scripts

Posted on 2011-02-12
25
589 Views
Last Modified: 2012-06-27
I have a logon script on our Windows 2008 server that maps drives to the users.  I am using the NET USE F: \\server\share  command.  I want to be able to disconnect the mapped drives when the user shutsdown so when they are using the computer away from the network the mapped drives will not be available.  We are having an issue in Excel 2007 where they are receiving the message Initializing Root Folder To Display when doing a Save As on a spreadsheet and it takes a long time to save.

I am testing the NET USE F: /delete command before I create a shutdown script and save it to the GPO.  When I run this command on a computer and then log back into the network the drive letter that I deleted does not reappear.  When I logged into the same computer as another user, creating a new profile, all the drives appear.  What could be causing the drives not to appear after using the NET USE /delete command?

Thanks,

Charlie
0
Comment
Question by:cfwirth
  • 12
  • 10
  • 3
25 Comments
 
LVL 47

Expert Comment

by:Donald Stewart
ID: 34880508
0
 

Author Comment

by:cfwirth
ID: 34880556
I am using group polcies to map the drives as a logon script.  If I want to disconnect them using a script should that be placed in the logoff scripts or shutdown scripts?
0
 
LVL 47

Expert Comment

by:Donald Stewart
ID: 34880572
You dont need logon scripts to map drives anymore(that was my point),  read the link :)
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 34883281
If you want to use logon scripts, which is what I do, instead of GP then this is what I suggest
Instead of the net use f: \\servername\sharename
do an IFstatement like this

if exist \\server\downloads net use l: \\server\downloads

That way if the user is on the network and connected if will make a network drive, if they are not if won't.

If you are worried about or having problems with Windows "remembering" the drive you can aad the persistent (remember) switch and set that to N (no)
if exist \\server\downloads net use l: \\server\downloads /p:n

Additionally, you can add a logoff script to delete all network drives when the users logoff or shut down, simply create a logoff script with a list of network drives and delete them like this

net use l: /d
net use m: /d
etc. etc,
0
 

Author Comment

by:cfwirth
ID: 34921250
I created a logoff script that contains the following:
 Net use * /delete /yes

I placed thisscript in the PDC's group policy. When I log into the server the mappings are present. When I shutdown the computer I see that the logoff scripts run on the computer but when I turn the computer back on while not connected to the network the share are still trying to connect.  If I run the net use * /delete /yes command at a command prompt it works and the shares are disconnected.  I am not sure why the logoff script is not working.  Any suggestios?

0
 
LVL 47

Expert Comment

by:Donald Stewart
ID: 34921301
If you use Group Policy Preferences to map your drives, you wont have any of these issues.
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 34921722
When you create the network connections are you using the persistent set to No switch?
if exist \\server\downloads net use l: \\server\downloads /p:n

Where the network connections originally created with net use statements of by using Windows Explorer?
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 34921751
What version of Windows are you doing your testing on?
0
 

Author Comment

by:cfwirth
ID: 34921781
Here is an example of how the commands were entered into the logon script.

 net use f: \\servername\sharename

I am using Windows 2008 Standard
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 34921806
Change it to
net use f: \\servername\sharename p:/n

Server is 2008, what about Clients--XP or Win 7
0
 

Author Comment

by:cfwirth
ID: 34921893
All clients are Win XP SP 3
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 34922018
Were the original connections created with net use or with Windows Explorer
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

Author Comment

by:cfwirth
ID: 34922396
With Net Use.
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 34922419
Now I am troubled--is this happening on all your PCs or just some? Did changing to using
net use f: \\servername\sharename p:/n
If you did, did that resolve it?
0
 

Author Comment

by:cfwirth
ID: 34922529
I haven't added /p:n yet.

0
 

Author Comment

by:cfwirth
ID: 34925945
I added the /p:n to the mappings and they still appear when not logged into the network.  When shutting down it shows that the logoff script is running but the net use * /delete /yes command does not work.  I can get it to work if I enter this command at a command prompt on the computer.
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 34927214
Well the only other option I can offer you is to use the logon script to clean up what the logoff script does not or else you may have to use GPO

Logon Script
if not exist \\server\downloads net use l: /d /y

or you can do what I do, this is from a production script that I use--what this does is that it will delete the network drive and will not reconnect if it is not on the network but if it is it will.

@Echo On
net use /p:n
Set Server=SQLServer

:Downloads
Net Use G: /d /y
Net Use G: \\%Server%\Downloads
GoTo PublicFolder

:PublicFolder
Net Use H: /d /y
Net use H: \\%Server%\PublicFolder
GoTo MS-Dynamics

:MS-Dynamics
Net Use M: /d /y
Net Use M: \\%Server%\MS-Dynamics
GoTo Users

:Users
Net Use U: /d /y
Net Use U: \\%Server%\%UserName%

:Exit
Exit
0
 

Author Comment

by:cfwirth
ID: 34928496
Well I think I figured out why the logoff script would not work. It was user error, on my part. I entered the command incorrectly.  I entered in net use *: /delete /yes.  I put a colon after the asterisk. Now the mappings are deleted when logging out of the network.  One question though. When I am not connected to the network and shutdown the computer it still says 'running logoff script'. I do not have a logoff script on the computer only on the PDC.   Why would it still show running a logoff script while not connected to the network?

Thanks for all the help.
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 34930571
If you are using the GPO to control logoff scripts and the PC is set to check for and run logoff scripts then it will look to see if there are logoff scripts to run. Do you have logon and logoff scripts set to run from a server share or do you have copies on each PC? If the latter then it will still run--if the former then it will just check but not actually run them.
0
 

Author Comment

by:cfwirth
ID: 34930622
I have the logon/logoff scripts on a server share and the GPO controls them.  There are no scripts on the PC itself.
0
 
LVL 24

Accepted Solution

by:
lionelmm earned 500 total points
ID: 34930761
So then it is just checking for and not actually running them. Are you familiar with gpupdate? This updates the local group policies from the central GPO (PDC) and so the PC get their instructions from the central GPO but store them locally, not the scripts, but the policy objects--make sense?
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 34930799
You can use MMC and the "Resultant set of Policy" snap-in to see how the central policy is stored (the resulk, changes) that are stored locally
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 34947813
Charlie--are we all set and done with this question? I think we are -- if not please let me know what else I can help you with on this-thanks!
0
 

Author Comment

by:cfwirth
ID: 34947843
I think everything works now.  Thanks for the help.
0
 
LVL 24

Expert Comment

by:lionelmm
ID: 34947860
Could you then close it and accept one of my answers as the solution please--thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Tired of waiting for your show or movie to load?  Are buffering issues a constant problem with your internet connection?  Check this article out to see if these simple adjustments are the solution for you.
I recently attended Cisco Live! in Las Vegas, a conference that boasted over 28,000 techies in attendance, and a week of hands-on learning hosted by a solid partner with which Concerto goes to market.  Every year, Cisco displays cutting-edge technol…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

939 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

10 Experts available now in Live!

Get 1:1 Help Now