Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Shutdown Computer Through C Program.

Shutdown Computer Through C Program.

Scheduled Pinned Locked Moved C#
help
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Droze
    wrote on last edited by
    #1

    hello all, I have been trying to make a program to shutdown my computer, i have the program on a timer and at a certian time i would like the program to shutdown my whole computer. i am planning on using it for when i am Burning dvds or listening to music before bed. i know that the command prompt has a command to shutdown a computer: /shutdown -s where u can also use [-t XX] where XX is the time till it shutdowns. Can someone please help me in this, either by using C to open and use command prompt by itself, or another way. Thank you Very much. - Droz - ___ ___ /\/\ /\ | |

    J D K 3 Replies Last reply
    0
    • D Droze

      hello all, I have been trying to make a program to shutdown my computer, i have the program on a timer and at a certian time i would like the program to shutdown my whole computer. i am planning on using it for when i am Burning dvds or listening to music before bed. i know that the command prompt has a command to shutdown a computer: /shutdown -s where u can also use [-t XX] where XX is the time till it shutdowns. Can someone please help me in this, either by using C to open and use command prompt by itself, or another way. Thank you Very much. - Droz - ___ ___ /\/\ /\ | |

      J Offline
      J Offline
      Jun Du
      wrote on last edited by
      #2

      In C#, you could simply call:

      System.Diagnostic.Process.Start("shutdown.exe", "-s -f -t 00");

      For more info, check this out: click here. - It's easier to make than to correct a mistake.

      D 1 Reply Last reply
      0
      • J Jun Du

        In C#, you could simply call:

        System.Diagnostic.Process.Start("shutdown.exe", "-s -f -t 00");

        For more info, check this out: click here. - It's easier to make than to correct a mistake.

        D Offline
        D Offline
        Droze
        wrote on last edited by
        #3

        Thank you so so very much. First time using this site and very impressed with the quick responce. Thank you Jun Du. - Droz - ___ ___ /\/\ /\ | |

        J 1 Reply Last reply
        0
        • D Droze

          Thank you so so very much. First time using this site and very impressed with the quick responce. Thank you Jun Du. - Droz - ___ ___ /\/\ /\ | |

          J Offline
          J Offline
          Jun Du
          wrote on last edited by
          #4

          You're welcome. Glad my answer is helpful. - It's easier to make than to correct a mistake.

          D 1 Reply Last reply
          0
          • J Jun Du

            You're welcome. Glad my answer is helpful. - It's easier to make than to correct a mistake.

            D Offline
            D Offline
            Droze
            wrote on last edited by
            #5

            Sorry to bother u even more, i ams ure u are very busy. but if it isn't to difficult, is there a way to send the app to my notification area? Atm it is on my taskbar. If this requires a lot of coding and is very difficult please just skip this:) i do not want you to spend all your time on me. Thank you very much Jun Du. - Droz - ___ ___ /\/\ /\ | |

            D 1 Reply Last reply
            0
            • D Droze

              Sorry to bother u even more, i ams ure u are very busy. but if it isn't to difficult, is there a way to send the app to my notification area? Atm it is on my taskbar. If this requires a lot of coding and is very difficult please just skip this:) i do not want you to spend all your time on me. Thank you very much Jun Du. - Droz - ___ ___ /\/\ /\ | |

              D Offline
              D Offline
              Droze
              wrote on last edited by
              #6

              oh sorry again, just at work atm and can not try out that code string u recommended i try. That is striaght C code right? Sorry if this is a dumb question, i am new to C coding and only been doing it for about 8 month. - Droz - ___ ___ /\/\ /\ | |

              D 1 Reply Last reply
              0
              • D Droze

                oh sorry again, just at work atm and can not try out that code string u recommended i try. That is striaght C code right? Sorry if this is a dumb question, i am new to C coding and only been doing it for about 8 month. - Droz - ___ ___ /\/\ /\ | |

                D Offline
                D Offline
                Dan Neely
                wrote on last edited by
                #7

                No. That was C# code. IF you're writing plain C you need to be asking in the c/c++ forum. C#'s a completely seperate language.

                1 Reply Last reply
                0
                • D Droze

                  hello all, I have been trying to make a program to shutdown my computer, i have the program on a timer and at a certian time i would like the program to shutdown my whole computer. i am planning on using it for when i am Burning dvds or listening to music before bed. i know that the command prompt has a command to shutdown a computer: /shutdown -s where u can also use [-t XX] where XX is the time till it shutdowns. Can someone please help me in this, either by using C to open and use command prompt by itself, or another way. Thank you Very much. - Droz - ___ ___ /\/\ /\ | |

                  D Offline
                  D Offline
                  Droze
                  wrote on last edited by
                  #8

                  Thank you, i was hoping it would be similar. thank you. - Droz - ___ ___ /\/\ /\ | |

                  1 Reply Last reply
                  0
                  • D Droze

                    hello all, I have been trying to make a program to shutdown my computer, i have the program on a timer and at a certian time i would like the program to shutdown my whole computer. i am planning on using it for when i am Burning dvds or listening to music before bed. i know that the command prompt has a command to shutdown a computer: /shutdown -s where u can also use [-t XX] where XX is the time till it shutdowns. Can someone please help me in this, either by using C to open and use command prompt by itself, or another way. Thank you Very much. - Droz - ___ ___ /\/\ /\ | |

                    K Offline
                    K Offline
                    Koushik Biswas
                    wrote on last edited by
                    #9

                    Though you are in the wrong forum, I will try. First of all, why this obsession with C? Why not a BAT file that has "/shutdown -s" typed in it, and use Windows Scheduler to run it whenevr you want? OK, so you are the "I will write my own program" kind of addict. Why not use the WinExec() Win32 API to execute the same BAT file? Create the BAT file and keep it somewhere on the hard disk. Now in the C program (which can take parameters like timer duration etc - that is your design, you can even pass the full path & name of theBAT file if you want your program to be generic) that will simply execute the BAT file at the specified time. Koushik Biswas

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups