Solved

vbscript that can tell if the user asked for a shutdown or restart

Posted on 2008-10-09
2
484 Views
Last Modified: 2008-10-10
Sorry I am really new to this.  im trying to write a logoff vbscript that can tell if my users requested to shutdown the computer or reboot it.
sort of like:
if reboot then X
if shutdown then Y

can someone provide me with some sample code that would accomplish this seemlessly without them needing to do any extra steps.

the purpose for this is to create a way for my users to quickly reboot their machines during work hours by bypassing large portions of the logoff script that typically take a lot of time.  Since my users dont work regular hours, i cant simply create a between the hours of arguement.

thank you for your reply
0
Comment
Question by:koffea
2 Comments
 
LVL 7

Accepted Solution

by:
Hubasan earned 400 total points
ID: 22680017
This is a simple logic question and the easiest way to do this I believe would be this:

1) instead of your users going to START/Reboot or Shutdown, you would create a batch file or VB script for them to restart or shutdown the PC.
2) This script would create a flag file depending on which action was requested: Reboot or shutdown.
3) Logoff script would detect this flag file (can be ordinary txt file) and bypass the logoff routine, and at the end would just delete that flag file. (or you can have startup/logon script delete the flag file). Last step is important because you don't want to leave that flag file since you don't want the to ALWAYS bypass the logoff script.

Example of restart request:
-User x wants to reboot the PC quickly and clicks on the shortcut on the desktop called "Quick reboot"
-This shortcut starts the batch file or VB Script that creates a flag file in C:\ drive called REBOOT.txt, and then initiates the "Shutdown -r" command to reboot the pc.
-Logoff script then recognizes that REBOOT.txt file exists with "IF EXIST "C:\Reboot.txt" then "bypass logoff script" and quickly restarts the PC.
0
 

Author Comment

by:koffea
ID: 22690917
i was hoping for something a lttle more transparent and seemless.  But your solution definitely works.  thanks.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 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

17 Experts available now in Live!

Get 1:1 Help Now