Solved

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

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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

707 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