3

I have to test the licensing mechanism of our application. One part of the test is to set the date to the past or future.

This worked well using my own PC, but it has some bad effects, e.g. if I save test reports, it will add the current date and time, which looks like I performed the test in the past or future. Also, since time is synchronized via NTP by our IT department, using my own PC does not work reliably any longer.

I tried using virtual PCs, but they tend to synchronize the time with the local PC. That can be turned off, but usually I want it turned on, so it's just inconvenient.

In another scenario, I am testing a client-server application and see what happens if the client time and server time differ. I'd like to do that on one machine without needing a second virtual OS just to change the time.

I wonder whether there's a more lightweight application that allows changing the time reported to a single application only. Something like a sandbox or an API hook.

Such a tool

  • must run on Windows (7 x64, 10 x64)
  • must be gratis
  • may be a command line tool
  • must change the offset of the clock reported to the application by some months to just a few minutes.

Note: I don't want to change file timestamps.

3

NirSoft RunAsDate was helpful.

RunAsDate is a small utility that allows you to run a program in the date and time that you specify. This utility doesn't change the current system date and time of your computer, but it only injects the date/time that you specify into the desired application.

It fulfills the requirements

  • works for Windows
  • is gratis
  • comes with a GUI but can also be run as a command line tool
  • can change the date/time in many ways, e.g. absolute or by offset

    RunAsDate.exe 22\10\2015 12:35:22
    RunAsDate.exe Hours:-10
    

I was not able to make it work in the first few attempts, because

  • the application started in a different working directory than expected. Creating a Desktop shortcut and changing the working directory manually in the shortcut helped
  • there seems to be a limitation in the length of Desktop shortcuts. A part of the command line parameters got cut, so the application didn't even start. When I changed that to a batch file, everything worked fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.