Echo out "Original Boot Time" from systeminfo command

Hey Experts!

I have a script that outputs the systeminfo from a remote computer.  This information is used for a couple of things but I'd like to improve on that script so that ONLY the "Original Boot Time" line is echo'd out, not the entire output of the command.

Suggestions on how to script this with a batch script, please.

Here is the masterpiece I wrote so far (holding back your LOL would be appreciated).  

set computeraudit=
set /p "computeraudit=Enter computer name: "

Open in new window

LVL 9
samiam41Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
NVITCommented:
> ...like to improve on that script so that ONLY the "Original Boot Time" line is echo'd
Can you share your script for review?
0
 
samiam41Author Commented:
Hi NVIT.  The script (all 2 lines) in located in the bottom portion of my question above.  Thanks!
0
 
samiam41Author Commented:
set computeraudit=
set /p "computeraudit=Enter in user's first name or string: "
for /f "tokens=2 delims=" %%a in ('systeminfo /s \\%computeraudit%' find /i "Original Boot Time"') do echo %%a

Open in new window


The last line does NOT work like I want it to so don't integrate it into your reply please.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
NVITCommented:
for /f "tokens=2 delims=" %%a in ('systeminfo /s \\%computeraudit%' ^| find /i "Boot Time"') do echo %%a

Open in new window

0
 
Gabriel CliftonNet AdminCommented:
Try something like this
for /f "tokens=2 delims='='" %%a in ('wmic os get lastbootuptime /value') do echo %%a
0
 
David Johnson, CD, MVPOwnerCommented:
Original Install Date:     02-Mar-2015, 7:49:26 PM
System Boot Time:          13-May-2015, 7:33:04 AM

Which do you want? The install date or the system boot time?
0
 
Bill PrewCommented:
Try this:

@echo off
set computeraudit=
set /p "computeraudit=Enter in user's first name or string: "
for /f "tokens=1 delims=" %%a in ('systeminfo /s \\%computeraudit% 2^>NUL ^| find /i "System Boot Time"') do echo %%a

Open in new window

~bp
0
 
samiam41Author Commented:
System Boot Time

Good catch!!  Dang oversight on my part.....
0
 
samiam41Author Commented:
@BP, that works.  Thanks!

I'm going to check the others real quick and then award points/close this out.

Thanks everyone!
0
 
Gabriel CliftonNet AdminCommented:
Here is a update to mine, much faster than systeminfo. Just for display here at least.

@echo off

for /f "tokens=2 delims='='" %%a in ('wmic os get lastbootuptime /value') do call :format %%a
pause
exit /b

:format
set long=%1
set nyear=%long:~0,4%
set nmonth=%long:~4,2%
set nday=%long:~6,2%
set nhour=%long:~8,2%
set nminute=%long:~10,2%

echo Last boot time: %nmonth%/%nday%/%nyear% at %nhour%:%nminute%
exit /b

Open in new window

0
 
samiam41Author Commented:
@NVIT, I copied your reply and used it as the last line in the script.  I get this error message when I use it:

ERROR:  The RPC server is unavailable



@Gabriel Clifton, it works.  Thanks.
0
 
samiam41Author Commented:
@GC, on the new one you posted, how do I enter in a remote hostname?
0
 
Gabriel CliftonNet AdminCommented:
Yes, i had just realized that

@echo off

for /f "tokens=2 delims='='" %%a in ('wmic /node:%computername% os get lastbootuptime /value') do call :format %%a
pause
exit /b

:format
set long=%1
set nyear=%long:~0,4%
set nmonth=%long:~4,2%
set nday=%long:~6,2%
set nhour=%long:~8,2%
set nminute=%long:~10,2%

echo Last boot time: %nmonth%/%nday%/%nyear% at %nhour%:%nminute%
exit /b

Open in new window

0
 
NVITCommented:
You get the RPC error just with mine? Did it work with Bill's?. Strange.
0
 
samiam41Author Commented:
@GC, that is way quicker.  I made one tweak as you used the variable "computername" instead of "computeraudit".

Very fast and clean script!
0
 
samiam41Author Commented:
@NVIT, here is the script I'm using (please verify I didn't fat-finger something)

@echo off
set computeraudit=
set /p "computeraudit=Enter computer name: "
for /f "tokens=2 delims=" %%a in ('systeminfo /s \\%computeraudit%' ^| find /i "Boot Time"') do echo %%a

Open in new window

0
 
Gabriel CliftonNet AdminCommented:
Was entering this in as I say your post hit. This will go with your prompt for computer name:
@echo off
echo.
set computeraudit=
set /p "computeraudit=Enter computer name: "
cls
echo.

for /f "tokens=2 delims='='" %%a in ('wmic /node:%computeraudit% os get lastbootuptime /value') do call :format %%a
echo.
pause
exit /b

:format
set long=%1
set nyear=%long:~0,4%
set nmonth=%long:~4,2%
set nday=%long:~6,2%
set nhour=%long:~8,2%
set nminute=%long:~10,2%

echo Computer %computeraudit%'s last boot time: %nmonth%/%nday%/%nyear% at %nhour%:%nminute%
exit /b

Open in new window


Of course, adjust for how you want the date displayed
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
Gabriel CliftonNet AdminCommented:
I think I see one of the issues on your script for NVIT

@echo off
set computeraudit=
set /p computeraudit=Enter computer name: 
for /f "tokens=2 delims=" %%a in ('systeminfo /s \\%computeraudit% ^| find /i "Boot Time"') do echo %%a
pause

Open in new window

0
 
Gabriel CliftonNet AdminCommented:
I kept getting blank with NVIT script so this is how I wrote it on testing, NVIT can you see any other issue with your script?

@echo off
set computeraudit=
set /p computeraudit=Enter computer name: 
for /f "tokens=2-4 delims=:" %%a in ('systeminfo /s \\%computeraudit% ^| find /i "Boot Time"') do echo %%a:%%b:%%c
pause

Open in new window

0
 
samiam41Author Commented:
Instead of "Boot Time", it needs to be "System Boot Time" and then it worked for me.

@NVIT, do you want to add anything?
0
 
samiam41Author Commented:
Thanks Experts!!  I greatly appreciate your time with this and did my best to balance out the points.  I look forward to working with you all again soon!

-Aaron
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.