?
Solved

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

Posted on 2008-10-09
2
Medium Priority
?
533 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 800 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
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…
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: …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

770 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