Execute Script On Shutdown BEFORE network connections close

I have a script I want to run at shutdown that copies a select few (important) employee's .pst(s) to a mapped "drive" on the network.  

This is being in lieu of an exchange server to have a tape backup of their very important e-mail.  

The problem is when I run a script from the group policy "on shutdown" the network connections close before scripts are run.

Any ideas on how to run this script on a shutdown event but before network connections close?
ClaudeWalkerAsked:
Who is Participating?
 
JohnConnect With a Mentor Business Consultant (Owner)Commented:
The way that policy works (I use it to disconnect drives amongst other things), I don't think so.

So if I were faced with this, I think what I would do is put a line in the script in front of the copy to map the specific drive, and then a line after the copy to disconnect the same drive.
... Thinkpads_User
0
 
ClaudeWalkerAuthor Commented:
PERFECT!!!!

Thank you very much!

NET USE Q: \\PHDATA\Josephk

del "Q:\Backup\TEAC\*.*" /q

del "Q:\Backup\My Documents\*.*" /q

del "Q:\Backup\OutlookBackup\*.*" /q

del "Q:\Backup\TEAC\*.*" /q

Copy "C:\Documents and Settings\josephk.PHI\My Documents\*.*" "Q:\Backup\My Documents\"

Copy "C:\Documents and Settings\josephk.PHI\Local Settings\Application Data\Microsoft\Outlook\*.*" "Q:\Backup\OutlookBackup\"

Copy "C:\Documents and Settings\josephk.PHI\Desktop\*.*" "Q:\Backup\Desktop\"

Copy "C:\TEAC\*.*" "Q:\Backup\TEAC\"

net use Q: /delete /YES
0
 
ClaudeWalkerAuthor Commented:
Uh Oh.

I spoke too soon.  When running the script by itself it works fine.  But running on shutdown it won't connect the drive after the network connections are closed.

Any ideas?  Is this because it disconnects from the domain?
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
micalkinConnect With a Mentor Commented:
how about running the script at logoff instead of at shutdown?
0
 
ClaudeWalkerAuthor Commented:
It works!  Is this a global policy or something that would have to be set up per user (logon)?

The running at logoff worked the only problem now is it won't copy all contents of the folder (directories).

Copy "C:\Documents and Settings\josephk.PHI\My Documents\*.*" "Q:\Backup\My Documents\"

Any ideas?
0
 
JohnBusiness Consultant (Owner)Commented:
If the script works (I use this kind of script frequently), then the issue of copying contents is probably a permissions issue within My Documents.  Also, you said you were copying .PST files (Email) and Outlook has to be closed completely for this to work.

Take subsets of files and test in pieces to see which files are not copying. It will have something to do with the above. ... Thinkpads_User
0
 
JohnBusiness Consultant (Owner)Commented:
Another (different and alternative) way to approach this is to make your own shutdown button. Make a batch file with your scripts that assumes the user has not shutdown. Add a shutdown command as the last line. Put a shortcut to the batch file on the user's Desktop. Ask the users to activate the desktop command to shutdown rather than use the Start button. Once they realize it is for their own safety, they will likely comply. My clients would. ... Thinkpads_User
0
 
ClaudeWalkerAuthor Commented:
It was basically all the directories.  The final and fully functional solution is to run the script at logoff.  This way we are not disconnected from the Domain.  Then I used xcopy which is more robust than copy and was able to copy subdirectories and all files.

This connects the network drive, deletes the network backup directories w/o prompt, then copies files w/o overwrite prompt and subdirectories, to be safe I disconnect the network drive.

Thanks a bunch this is exactly what I was looking for.


NET USE Q: \\PHDATA\Josephk

del "Q:\Backup\My Documents\*.*" /q

del "Q:\Backup\OutlookBackup\*.*" /q

del "Q:\Backup\Desktop\*.*" /q

xCopy "C:\Documents and Settings\josephk.PHI\My Documents\*.*" "Q:\Backup\My Documents\" /q /s

xCopy "C:\Documents and Settings\josephk.PHI\Local Settings\Application Data\Microsoft\Outlook\*.*" "Q:\Backup\OutlookBackup\" /q /s

xCopy "C:\Documents and Settings\josephk.PHI\Desktop\*.*" "Q:\Backup\Desktop\" /q /s

net use Q: /delete /YES

Open in new window

0
 
ClaudeWalkerAuthor Commented:
Thanks a bunch
0
 
JohnBusiness Consultant (Owner)Commented:
Thanks and good luck. ... Thinkpads_User
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.