Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Logoff scripts to run only on LOG OFF

Posted on 2004-03-25
7
Medium Priority
?
932 Views
Last Modified: 2010-04-13
I set a logoff script for domain that backs up files to the server when users log off their workstations and it works fine. The problem is that it executes also when they restart their machines when they have to. That is a big inconvenience because depending on the size of the files that are being backed up, it may take a while. For one user, it took her 40 minutes to restart her computer.

I am wondering, is there a way to configure Windows 2000 so that logoff scripts run ONLY when a user clicks Start, Log off ? So that they run only on forced Log Off??
0
Comment
Question by:njava
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 16

Expert Comment

by:JamesDS
ID: 10685053
In a word, no - sorry!

The logoff event is called during the shutdown request, there is no way around this.

An alternative might be to insert a question in the the script that asks if they want to run the script and if there is no response after 5 seconds, then gets on a runs it anyway. That way a user doing a reboot gets the choice of a full backup.

Cheers

JamesDS
0
 
LVL 1

Author Comment

by:njava
ID: 10761853
Oh, for some reasons I don't get a notification anymore when someone replies to my post.

Do you have any suggestions how to modify the script? How to do something like this:

ECHO <PRESS ANY KEY TO EXIT LOG OFF SCRIPT>
IF KEYPRESSED
   EXIT
0
 
LVL 1

Author Comment

by:njava
ID: 10762112
I came with an idea...how to generate Anykey stroke???


ECHO <PRESS ANY KEY TO EXIT LOG OFF SCRIPT>
SET Anykey =
IF '%Anykey%' ==
EXIT
SLEEP 20

:: MY SCRIPT STARTS HERE
0
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 
LVL 16

Accepted Solution

by:
JamesDS earned 300 total points
ID: 10763464
njava

Batch language doesn't work like this as it will continue processing regardless of user input. I suggest you write a short bit of VBScript code that ask the user for input and then sets a variable that either exits or continues the batch file.

Try this VBScript code and use it to call your logoff script. It will ask the user a question and act on the result:

Set WshShell = Wscript.CreateObject("Wscript.Shell")

strInput = MsgBox("Do you want to shutdown?",vbokcancel,"Logoff and backup script")

If strInput = 1 Then wshShell.run("logoff.bat") ' They pressed ok
If strInput = 2 Then WScript.Quit ' They pressed cancel

Cheers

JamesDS
0
 
LVL 1

Author Comment

by:njava
ID: 10770253
I modified logoff.vbs script a bit. Is there any way to make two buttons - Logoff and Restart instead of Yes and No?


Set wshShell = WScript.CreateObject("Wscript.Shell")

strInput = MsgBox("Do you want to Logoff or Restart your computer?", vbQuestion + vbYesNo, "Select Logoff or Restart")

If strInput = 1 Then wshShell.Run ("backup.bat") ' They pressed Logoff
If strInput = 2 Then WScript.Quit ' They pressed Restart
0
 
LVL 1

Author Comment

by:njava
ID: 10770525
I worked out a solution :-) The problem is that to set a custom button in Visual Basic you'd have to make a separate form and then assign a code to each button. I am not sure if this is possible in VBS. I re-designed the script again. It's easy to understand and it works. I graded your answer "B" because I still had to pull out a lot of my own hair :-) Thanks for your help anyway!


Set wshShell = WScript.CreateObject("Wscript.Shell")

strInput = MsgBox("Do you want to backup your e-mail?", vbQuestion + vbYesNo, "Select Yes or No")

If strInput = 6 Then wshShell.Run ("backup.bat") ' They pressed Yes
If strInput = 7 Then WScript.Quit ' They pressed No
0
 
LVL 1

Author Comment

by:njava
ID: 10779030
My troubles with logoff scripts are not over...in fact, it doesn't work...well, if you want to participate, I posted another question on that topic at.

http://www.experts-exchange.com/Operating_Systems/Win2000/Q_20947113.html
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

636 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