Solved

Logoff scripts to run only on LOG OFF

Posted on 2004-03-25
7
925 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
In  today’s increasingly digital world, managed service providers (MSPs) fight for their customers’ attention, looking for ways to make them stay and purchase more services. One way to encourage that behavior is to develop a dependable brand of prod…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 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

20 Experts available now in Live!

Get 1:1 Help Now