Solved

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

Posted on 2008-10-09
2
497 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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