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
Solved

Terminal Services - VBScript - Trying to log off user with warning / delay

Posted on 2013-06-28
6
473 Views
Last Modified: 2013-07-03
I have the following piece of code that forcefully logs a user off of a terminal server right away:

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.run "shutdown.exe -L -F"

Open in new window


That works perfectly. I'm trying to introduce the -T variable to it so that it logs off with a warning, but when I do the command doesn't run.

Is this possible?
0
Comment
Question by:street9009
  • 3
  • 2
6 Comments
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 39286286
for my pc (win8), the switches to shutdown are / prefixed.

but also the help notes that using /t implies /f so
shutdown /l /t 045

Open in new window

  should be the same
0
 

Author Comment

by:street9009
ID: 39290526
Somehow this shutdown.exe that's being called in VBScript is different than the traditional command line version. I notice that the -F is being called with a - and not a / for starters. And when I add /t or -T or -t, it doesn't run. I don't know how or why it's different, but something is.
0
 
LVL 15

Expert Comment

by:ZabagaR
ID: 39294430
What OS and edition? Windows 2008 R2 for instance?

From what I've read, you cannot use the /l parameter and the /t parameter together.

I tried it myself on a Windows 2008 terminal server, same issue as you.

http://pcsupport.about.com/od/commandlinereference/p/shutdown-command.htm
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:street9009
ID: 39296736
Correct, Server 2008 R2. I'm trying to force a polite log-off with at least a little warning.
0
 
LVL 15

Accepted Solution

by:
ZabagaR earned 500 total points
ID: 39296910
Put this code in front of your own log off script:

A box will pop up telling the user that they'll be logged out in 5 seconds (TIMEOUT value).
If they wait 5 seconds, the box will disappear and they'll be logged out.  If they click the OK button before 5 seconds they'll be logged out.

Const TIMEOUT = 5
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Popup "Logging off in 5 seconds", TIMEOUT
0
 

Author Closing Comment

by:street9009
ID: 39297997
Worked like a champ. Thank you!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

808 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