[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Logon and Shutdown Scripts

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
cfwirth
Asked:
cfwirth
  • 12
  • 10
  • 3
1 Solution
 
Donald StewartNetwork AdministratorCommented:
0
 
cfwirthAuthor Commented:
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
 
Donald StewartNetwork AdministratorCommented:
You dont need logon scripts to map drives anymore(that was my point),  read the link :)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Lionel MMSmall Business IT ConsultantCommented:
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
 
cfwirthAuthor Commented:
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
 
Donald StewartNetwork AdministratorCommented:
If you use Group Policy Preferences to map your drives, you wont have any of these issues.
0
 
Lionel MMSmall Business IT ConsultantCommented:
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
 
Lionel MMSmall Business IT ConsultantCommented:
What version of Windows are you doing your testing on?
0
 
cfwirthAuthor Commented:
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
 
Lionel MMSmall Business IT ConsultantCommented:
Change it to
net use f: \\servername\sharename p:/n

Server is 2008, what about Clients--XP or Win 7
0
 
cfwirthAuthor Commented:
All clients are Win XP SP 3
0
 
Lionel MMSmall Business IT ConsultantCommented:
Were the original connections created with net use or with Windows Explorer
0
 
cfwirthAuthor Commented:
With Net Use.
0
 
Lionel MMSmall Business IT ConsultantCommented:
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
 
cfwirthAuthor Commented:
I haven't added /p:n yet.

0
 
cfwirthAuthor Commented:
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
 
Lionel MMSmall Business IT ConsultantCommented:
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
 
cfwirthAuthor Commented:
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
 
Lionel MMSmall Business IT ConsultantCommented:
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
 
cfwirthAuthor Commented:
I have the logon/logoff scripts on a server share and the GPO controls them.  There are no scripts on the PC itself.
0
 
Lionel MMSmall Business IT ConsultantCommented:
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
 
Lionel MMSmall Business IT ConsultantCommented:
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
 
Lionel MMSmall Business IT ConsultantCommented:
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
 
cfwirthAuthor Commented:
I think everything works now.  Thanks for the help.
0
 
Lionel MMSmall Business IT ConsultantCommented:
Could you then close it and accept one of my answers as the solution please--thanks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 12
  • 10
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now