0

Hi I am trying to change the date and time settings for my machine to a date in the future. however this is causing it to just increase by a day and cause a long delay from running my tests

- I have tried seeing if there was a registry entry I could use to modify time

    public void ChangeDate()
    {
        Process p = new Process();
        p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        p.StartInfo.FileName = "cmd.exe";
        ProcessStartInfo commandInfo = new ProcessStartInfo("cmd.exe");
        commandInfo.WorkingDirectory = @"c:\Windows\System32\";
        p.StartInfo.UseShellExecute = false;

        p.StartInfo.RedirectStandardInput = true;
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.Verb = "runas";
        p.Start();
        p.StandardInput.WriteLine(@"cd c:\Windows\System32");
        p.StandardInput.WriteLine("date 12-10-2019");


        p.WaitForExit();
        Console.WriteLine("Time Has Changed");

expected results: The date to change to 12-10-2019. actual results: Specflow Feature file hangs. Date is forwarded by one day. Todays date is 08/09/2019 so it changes to 08/10/2019

haldo
  • 14,512
  • 5
  • 46
  • 52
Jnewbie
  • 1
  • 2
  • According to the documentation at https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/date, you need administrative privileges for `date`. BTW, I'm surprised to find a command with the horrible M/D/Y date format. – Palle Due Aug 09 '19 at 08:45
  • Hi Palle, i have administrative privileges however it still does not run my feature. It just lags and I have no idea how to check what is going on. – Jnewbie Aug 09 '19 at 12:30

0 Answers0