<p>How do you set the Windows time zone on the local machine programmatically in C#?  Using an interactive tool is not an option because the remote units have no user interface or users.  The remote machine is running .NET 2.0 and Windows XP Embedded and a local app that communicates with a central server (via web service) for automated direction of its tasks.  We can deliver a command to synch to a certain time/zone combination, but what code can be put in the local app to accomplish the change?  The equipment is not imaged for specific locations before installation, so in order to use any equipment at any location, we have to be able to synch this information.</p>

[{'answer_id': 32743, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': True, 'text': '<p><a href="http://msdn.microsoft.com/en-us/library/ms724944.aspx" rel="nofollow noreferrer">SetTimeZoneInformation</a> should do what you need. You\'ll need to use <a href="http://pinvoke.net/default.aspx/kernel32/SetTimeZoneInformation.html" rel="nofollow noreferrer">P/Invoke</a> to get at it.</p>\n\n<p>Note also that you\'ll need to possess and enable the SE_TIME_ZONE_NAME privilege.</p>\n'}, {'answer_id': 32779, 'author': 'Jason Bunting', 'author_id': 1790, 'author_profile': 'https://Stackoverflow.com/users/1790', 'pm_score': 0, 'selected': False, 'text': '<p>Try this...</p>\n\n<p>First, you need to find, in the registry, the <strong>key</strong> that represents the zone you want ("Central Standard Time" is an example). Those are located here:</p>\n\n<blockquote>\n  <p>HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\Current Version\\Time Zones</p>\n</blockquote>\n\n<p>So, with that in mind, create a batch file, "SetTimeZone.bat" with the following line in it:</p>\n\n<blockquote>\n  <p>RunDLL32 shell32.dll,Control_RunDLL %SystemRoot%\\system32\\TIMEDATE.cpl,,/Z %1</p>\n</blockquote>\n\n<p>From C#, call:</p>\n\n<blockquote>\n  <p>System.Diagnostics.Process.Start("SetTimeZone.bat", "The key of the time zone you want to set");</p>\n</blockquote>\n'}, {'answer_id': 32864, 'author': 'Brian Leahy', 'author_id': 580, 'author_profile': 'https://Stackoverflow.com/users/580', 'pm_score': 0, 'selected': False, 'text': "<p>You will run the risk of having incorrect data if you do not use UTC to transmit dates... If you change time zones on the device... you're dates will be even further off.</p>\n\n<p>You may want to use UTC and then calculate time in each timezone.  </p>\n"}, {'answer_id': 2055210, 'author': 'Santhosh', 'author_id': 249594, 'author_profile': 'https://Stackoverflow.com/users/249594', 'pm_score': 1, 'selected': False, 'text': '<p>This is not working in Windows 7. I have tried with the following environment\nwindows 7\nVSTS-2008\nIt is opening Change Time Zone Window as we do it manually</p>\n'}, {'answer_id': 2055308, 'author': 'Oliver', 'author_id': 1838048, 'author_profile': 'https://Stackoverflow.com/users/1838048', 'pm_score': 0, 'selected': False, 'text': '<p>Instead of just setting the time zone of some systems you should consider to use the Windows Time Service. It will not only handle the time zone. It will also take care about correct settings of date and time itself.</p>\n\n<p>Take a look at: <a href="http://support.microsoft.com/kb/307897/en-us" rel="nofollow noreferrer">How to synchronize the time with the Windows Time service in Windows XP</a></p>\n\n<p>Even if you maybe going to make all these settings within Vista or Windows 7 take a look at <a href="http://technet.microsoft.com/en-us/library/cc749145(WS.10).aspx" rel="nofollow noreferrer">this here</a>.</p>\n'}, {'answer_id': 2161625, 'author': 'offler', 'author_id': 261775, 'author_profile': 'https://Stackoverflow.com/users/261775', 'pm_score': 1, 'selected': False, 'text': '<blockquote>\n  <p>santosh \n  you are definitly correct. RunDLL32 shell32.dll,Control_RunDLL %SystemRoot%\\system32\\TIMEDATE.cpl,,/Z %1\n  is deprecated for years and will neither run on Windows 2008, R2, Vista, 7, ...\n  oh, yes i noticed that this forum seems to have a complete bug with recognizing the enter key. maybe someday the programmer will fix that problem.</p>\n</blockquote>\n'}]
['https://Stackoverflow.com/questions/32718', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3457/']