Skip navigation

JSI Tip 9742. How can a script return the date and time that my computer was last started?


Using standard commands, I have scripted WhenStarted.bat to return the date and time that your computer was last started.

The syntax for using WhenStarted.bat is:

WhenStarted Date Time

Where:

DATE is a call directed environment variable that will contain the date your computer was started,
     using your short date format.

Time is a call directed environment variable that will contain the time your computer was started.
WhenStarted.bat contains:
@echo off
if \{%2\}==\{\} @echo WhenStarted Date Time&goto :EOF
for /f "Tokens=3,4" %%a in ('net statistics server^|Find "Statistics since"') do (
 set %1=%%a
 set %2=%%b
)



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish