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. Setting System Time

Setting System Time

Scheduled Pinned Locked Moved C#
csharpquestion
6 Posts 3 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
    dwebster
    wrote on last edited by
    #1

    Does anyone know the best method to use to set the system time using C#? I am looking for the best way to programmatically set the time on my computer. Thanks!

    M R 2 Replies Last reply
    0
    • D dwebster

      Does anyone know the best method to use to set the system time using C#? I am looking for the best way to programmatically set the time on my computer. Thanks!

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      For this purpose I couldn't find anything more than API SetSystemTime().Its very hard for me to use win32 API in C# but for some jobs its the only way. Mazy **"If I go crazy then will you still Call me Superman If I’m alive and well, will you be There holding my hand I’ll keep you by my side with My superhuman might Kryptonite"**Kryptonite-3 Doors Down

      1 Reply Last reply
      0
      • D dwebster

        Does anyone know the best method to use to set the system time using C#? I am looking for the best way to programmatically set the time on my computer. Thanks!

        R Offline
        R Offline
        Ragavendran Vaidhyanadhan
        wrote on last edited by
        #3

        There are few suggestions i 've. Try using "shell32" interop and Shell32.shell app = new Shell32.shell(); app.SetTime(); This display the Date/Time properties.. If you still wanna change it programmatically , you cxan try running the time system command by creating a Process. Process myProcess = new Process(); ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("time" "3"); myProcess.StartInfo = myProcessStartInfo.UseShellExecute; myProcess.Start(); Ragavendran Vaidhyanadhan

        M 1 Reply Last reply
        0
        • R Ragavendran Vaidhyanadhan

          There are few suggestions i 've. Try using "shell32" interop and Shell32.shell app = new Shell32.shell(); app.SetTime(); This display the Date/Time properties.. If you still wanna change it programmatically , you cxan try running the time system command by creating a Process. Process myProcess = new Process(); ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("time" "3"); myProcess.StartInfo = myProcessStartInfo.UseShellExecute; myProcess.Start(); Ragavendran Vaidhyanadhan

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #4

          I run "time" but there is no such a file.Could you tell me the name of file that is for Date/Time property? Mazy **"If I go crazy then will you still Call me Superman If I’m alive and well, will you be There holding my hand I’ll keep you by my side with My superhuman might Kryptonite"**Kryptonite-3 Doors Down

          R 1 Reply Last reply
          0
          • M Mazdak

            I run "time" but there is no such a file.Could you tell me the name of file that is for Date/Time property? Mazy **"If I go crazy then will you still Call me Superman If I’m alive and well, will you be There holding my hand I’ll keep you by my side with My superhuman might Kryptonite"**Kryptonite-3 Doors Down

            R Offline
            R Offline
            Ragavendran Vaidhyanadhan
            wrote on last edited by
            #5

            Mazdak wrote: I run "time" but there is no such a file Hi Here, "Time " refers to the internal system built command. Try creating a temp file called "time.bat" and write "time 2:45" into it ( just like how you specify the time command in the command line .. ) and use the file to create the startupinfo. I am sure it will work. :) Ragavendran Vaidhyanadhan

            D 1 Reply Last reply
            0
            • R Ragavendran Vaidhyanadhan

              Mazdak wrote: I run "time" but there is no such a file Hi Here, "Time " refers to the internal system built command. Try creating a temp file called "time.bat" and write "time 2:45" into it ( just like how you specify the time command in the command line .. ) and use the file to create the startupinfo. I am sure it will work. :) Ragavendran Vaidhyanadhan

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

              Thanks, guys... I will try these ideas.

              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