Solved

Logoff scripts to run only on LOG OFF

Posted on 2004-03-25
7
927 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
  • 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 16

Accepted Solution

by:
JamesDS earned 100 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

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…
Read about the ways of improving workplace communication.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

18 Experts available now in Live!

Get 1:1 Help Now