Solved

Logoff scripts to run only on LOG OFF

Posted on 2004-03-25
7
929 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Recovering backup .Qic files on Windows 7 6 2,306
Windows WEb Server sp2 13 524
Server 2012 R2 added to a Windows 2000 domain 3 89
Windows Services - Run a Program Grey Out 3 93
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…
Building a cohesive image for your brand is vital to making an impression on consumers. When the economy is tough, brands do better than unbranded  products. This can have a huge impact on your long-term profits, as the economy goes up and down.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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