Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

I'm a n00b but please help me out.


  • Please log in to reply

#1
ian walker

ian walker

    New Member

  • Member
  • Pip
  • 5 posts
Okay so, I'm trying to make a button that will shut down a computer when hit. The problem is, I can't figure out what is wrong with the code I'm using.


____________________________________________________________
ProcessStartInfo startinfo = new ProcessStartInfo("shutdown.exe","-s");
Process.Start(startinfo);
____________________________________________________________

Should that work? Am I doing something wrong?


Help please.
  • 0

Advertisements


#2
Retired Tech

Retired Tech

    Retired Staff

  • Retired Staff
  • 20,563 posts
You could use this

shutdown.exe will NOT work on Windows 95, 98, 98 SE and ME!

shutdown.exe is a command line utility. This means you have to first run Command Prompt (cmd.exe) from the Start menu and then run shutdown with any combination of switches.

Alternatively, you can also create a shortcut to the shutdown.exe and shutdown your computer by double clicking the icon on your desktop.

To run the shutdown.exe from the Command Prompt:
1. On the Start menu click Run.
2. Type cmd.exe and click OK.
3. Go to the folder with my shutdown utility. If my shutdown.exe is in c:\shutdown type "cd /d c:\shutdown" in the command line. If you fail to do this, you will run the shutdown.exe that is built-in into Windows XP.
4. You can get a list of all supported switches by typing shutdown.


To create a shortcut to shutdown.exe:
1. Right click your dekstop and select New and then click Shortcut.
2. Click the Browse button and go trough your hard drive and select my shutdown.exe. Click OK.
3. In the box with the path to the shutdown.exe add a switch depending on the action you want to perform. For instance, if you want to shutdown your computer add -u in the box. For all supported switched see below.
4. Click Next.
5. Type a descriptive name in the box, like Shutdown computer and click Finish.
6. You can now shutdown your computer by double clicking the icon on your desktop.


Supported switches:
-l -> Log Off.
-u -> Shutdown (Turn Off).
-r -> Restart.
-h -> Hibernate.
-s -> Stand By (Sleep).
-f -> Force the action.
-c -> Cancel a running shutdown.
-t sec -> Delay for number of seconds.


Usage examples:


Log off current user and forces quick shutdown of applications: shutdown -l -f
Initate standby in 30 seconds: shutdown -s -t 30
Cancel all initiated actions: shutdown -c
Shut the computer down: shutdown -u
Restart the computer: shutdown -r
Hibernate the computer: shutdown -h
Wait 10 seconds before shutting down the computer: shutdown -u -t 10
Assign original Windows icons to the shortcut:
1. Right click on the shortcut to the shutdown.exe you created on the dekstop and select properties.
2. Click the Change icon button. A dialog will appear. Just click OK.
3. Click the Browse button and select \windows\system32\shell32.dll and click Open. 4. New dialog will appear listing all the icons in this file. You will also find the same icons that appear on your Start menu. Select the icon you would like to assing to the shortcut and click OK.
5. Click OK.


Assign shortcut key:
1. Right click on the shortcut to the shutdown.exe you created on the dekstop and select properties.
2. Click in the Shurtcut key box and a, like S. This will configure the shortcut to run when you press Ctrl + Alt + S on your keyboard (you have to press all three keys Ctrl, Alt and S at the same time).
3. Click OK.


http://www.budja.com/shutdown/
  • 0

#3
ian walker

ian walker

    New Member

  • Topic Starter
  • Member
  • Pip
  • 5 posts
Well, here was my idea, I wanted to put a shutdown button on my website disguised as something else... (to freak people out when their computer suddenly shut down). So the shortcut doesn't really work, and all I got from cmd.exe was:

-i
-l
-r
-s
etc blah blah

Sorry, I'm noobin' out over here
  • 0

#4
ian walker

ian walker

    New Member

  • Topic Starter
  • Member
  • Pip
  • 5 posts
Bump, lol

please help.
  • 0

#5
Retired Tech

Retired Tech

    Retired Staff

  • Retired Staff
  • 20,563 posts
The intended use is dubious

Its success unlikely
  • 0

#6
ian walker

ian walker

    New Member

  • Topic Starter
  • Member
  • Pip
  • 5 posts

The intended use is dubious

Its success unlikely


It's harmless fun.
  • 0

#7
Retired Tech

Retired Tech

    Retired Staff

  • Retired Staff
  • 20,563 posts
If it were possible (legally and without resorting to virus writing) it would have been done, and 99% of all PC's would be in a reboot cycle

We can all hope that nobody ever bothers to figure out a way to do it
  • 0

#8
ian walker

ian walker

    New Member

  • Topic Starter
  • Member
  • Pip
  • 5 posts
Lol, well I'm workin' on it :tazz:
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP