I want change date on server (my test env) from mvc application. I tried use windows api function SetSystemTime([InAttribute()] ref SystemTime lpSystemTime) but it doesn't work. It's possible to change server system time from web app?
I have test environment where I want to test functions of my web app which fires in some time periods (e.g. monthly sending reports). I konow that I can change time in system directly, but it's environment for testers (they had not acces to server).
A.Venkatesan
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
snajp3er
Member
97 Points
26 Posts
Set server system date from web app
Feb 17, 2012 01:10 PM|LINK
Hi,
I want change date on server (my test env) from mvc application. I tried use windows api function SetSystemTime([InAttribute()] ref SystemTime lpSystemTime) but it doesn't work. It's possible to change server system time from web app?
server datetime windows change
budugu
All-Star
41132 Points
6021 Posts
Re: Set server system date from web app
Feb 17, 2012 01:38 PM|LINK
I don't think you can change server time from web app. But why do you want to do that?
"Don't be afraid to be wrong; otherwise you'll never be right."
snajp3er
Member
97 Points
26 Posts
Re: Set server system date from web app
Feb 17, 2012 01:53 PM|LINK
I have test environment where I want to test functions of my web app which fires in some time periods (e.g. monthly sending reports). I konow that I can change time in system directly, but it's environment for testers (they had not acces to server).
venkatmca008
Participant
1810 Points
341 Posts
Re: Set server system date from web app
Feb 17, 2012 01:56 PM|LINK
please refer this.....
http://forums.asp.net/t/638253.aspx/1
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
snajp3er
Member
97 Points
26 Posts
Re: Set server system date from web app
Feb 17, 2012 02:03 PM|LINK
I saw it. So it's not possible? It's bad news for me :(
snajp3er
Member
97 Points
26 Posts
Re: Set server system date from web app
Feb 29, 2012 01:01 PM|LINK
I found solution. I used cmd.exe date :) It works fine
public string NewDateTime { get; set; } public void SetServerTime() { ProcessStartInfo psi = new ProcessStartInfo("cmd.exe"); psi.RedirectStandardInput = true; psi.RedirectStandardOutput = true; psi.UseShellExecute = false; psi.Arguments = @"/C date " + NewDateTime; Process p = Process.Start(psi); }