views:

5255

answers:

9

I've been using Remote Desktop to get into a workstation but I'm not able to use the shutdown/restart function in the Start menu while doing this.

I've put a few really helpful options in the answer below.

As I cannot accept this answer, please vote up if you find it appropriate.

Note:
I wanted to make sure some really good answers were also mentioned along with my own on this.

And here they are in no particular order.

Thanks for participating guys! Great answers all.

+19  A: 

Here's how to do the shutdown functions via a batch file.

shutdown -r ;;restarts
shutdown -s ;;shutsdown
shutdown -l ;;logoff
shutdown -t xx ;;number of seconds to wait till shutdown/restart/logoff
shutdown -i ;;gives you a dialog box to fill in what function you want to use
shutdown -a ;;aborts the previous shutdown command....very handy!

Keng
+5  A: 

In a remote desktop session, you can also Ctrl + Alt + End to pull up the Task Manager and select Shutdown from the tool bar.

You can also right click on the task bar to pull up the Task Manager.

Ctrl + Shift + Esc will also work. (From Rich B)

Owen
oooooo....nice thought!
Keng
Cool, I never knew about Ctrl+Alt+End, and it has been the source of a lot of frustration over the years.
Kip
+6  A: 

If you are on a remote machine, you may also want to add the -f option to force the reboot. Otherwise your session may close and a stubborn app can hang the system.

I use this whenever I want to force an immediate reboot:

shutdown -t 0 -r -f

Brutus 2006 is a utility that provides a GUI for these options.

JosephStyons
very good point!
Keng
+3  A: 

You also got all the "rundll32.exe shell32.dll" serie:

  • rundll32.exe user.exe,ExitWindows [Fast Shutdown of Windows]
  • rundll32.exe user.exe,ExitWindowsExec [Restart Windows]

    rundll32.exe shell32.dll,SHExitWindowsEx n

where n stands for:

  • 0 - LOGOFF
  • 1 - SHUTDOWN
  • 2 - REBOOT
  • 4 - FORCE
  • 8 - POWEROFF

(can be combined -> 6 = 2+4 FORCE REBOOT)

VonC
woot!....let your freak flag fly VonC! nice.
Keng
+2  A: 

When remoted into a machine (target is XP anyway, not sure about target Vista), although Shutdown on the start menu is replaced by Disconnect Session or something like that, there should be one called 'Windows Security' which also does the same thing as Ctrl+Alt+End as pointed to by Owen.

Carl
+2  A: 

You're probably aware of this, but just in case: it's much easier to just type "shutdown -r" (or whatever command you like) into the "Run" box and hit enter.

Saves leaving batch files lying around everywhere.

Dean
yep...I just like to have the double-click sitting there...that's what the -r bat file is for too ;o)
Keng
careful not to put it in programs->startup :)
Dean
HAHAHAHA!!! awesome!
Keng
A: 

hi can some one please write a full code if I want to log off plz im a complete beginer and wants some help! I want to run batch file when the user logs off if any one who have the code please write it thanx

that's not really what's going on here. you want a batch file to trigger WHEN someone logs off and that's an administration thing. do a search for that then put your batch file in there.
Keng
+3  A: 

No one has mentioned -m option for remote shutdown:

shutdown -r -f -m \\machinename

Also:

  • The -r parameter causes a reboot (which is usually what you want on a remote machine, since physically starting it might be difficult).
  • The -f parameter option forces the reboot.
  • You must have appropriate privileges to shut down the remote machine, of course.
Kip
+1  A: 

I would write this in notepad or wordpad for a basic logoff command...

@echo off shutdown -l

this is basically the same as clicking start and logoff manualy just slightly faster if you have the batch file ready.

Grant