Solved

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

Posted on 2013-06-28
6
475 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

726 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