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. Automatic Server Shutdown

Automatic Server Shutdown

Scheduled Pinned Locked Moved C#
csharpsysadminlinuxtutorial
4 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.
  • F Offline
    F Offline
    FJJCENTU
    wrote on last edited by
    #1

    I would like that my Server (Windows 2003) automaticly shutdown at 20.00 and for it I think that the Best solution is to create a Net C# Windows Service, but could anybody tell me the C# command for getting the system down, I know that inside the Operating System the order is ShutDown but how to access the Operative System from inside the C# code, not existing shell orders as in older languages. Best Regards

    D D D 3 Replies Last reply
    0
    • F FJJCENTU

      I would like that my Server (Windows 2003) automaticly shutdown at 20.00 and for it I think that the Best solution is to create a Net C# Windows Service, but could anybody tell me the C# command for getting the system down, I know that inside the Operating System the order is ShutDown but how to access the Operative System from inside the C# code, not existing shell orders as in older languages. Best Regards

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      There are several alternatives on this SO thread[^].

      Dave

      If this helped, please vote & accept answer!

      Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

      1 Reply Last reply
      0
      • F FJJCENTU

        I would like that my Server (Windows 2003) automaticly shutdown at 20.00 and for it I think that the Best solution is to create a Net C# Windows Service, but could anybody tell me the C# command for getting the system down, I know that inside the Operating System the order is ShutDown but how to access the Operative System from inside the C# code, not existing shell orders as in older languages. Best Regards

        D Offline
        D Offline
        David Skelly
        wrote on last edited by
        #3

        This may be a dumb question from me but why can't you just use the Task Scheduler to schedule a shutdown at the required time?

        1 Reply Last reply
        0
        • F FJJCENTU

          I would like that my Server (Windows 2003) automaticly shutdown at 20.00 and for it I think that the Best solution is to create a Net C# Windows Service, but could anybody tell me the C# command for getting the system down, I know that inside the Operating System the order is ShutDown but how to access the Operative System from inside the C# code, not existing shell orders as in older languages. Best Regards

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Why would you need to write any code at all since you can just put a SHUTDOWN command line in a Scheduled Task job? Open a CMD prompt and type shutdown /? for the command line options.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008
          But no longer in 2009...

          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