Solved

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

Posted on 2013-06-28
6
466 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now