Solved

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

Posted on 2013-06-28
6
471 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

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…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 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