samiam41
asked on
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).
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: "
ASKER
Hi NVIT. The script (all 2 lines) in located in the bottom portion of my question above. Thanks!
ASKER
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
The last line does NOT work like I want it to so don't integrate it into your reply please.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
System Boot Time: 13-May-2015, 7:33:04 AM
Which do you want? The install date or the system boot time?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
System Boot Time
Good catch!! Dang oversight on my part.....
Good catch!! Dang oversight on my part.....
ASKER
@BP, that works. Thanks!
I'm going to check the others real quick and then award points/close this out.
Thanks everyone!
I'm going to check the others real quick and then award points/close this out.
Thanks everyone!
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
ASKER
@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.
ERROR: The RPC server is unavailable
@Gabriel Clifton, it works. Thanks.
ASKER
@GC, on the new one you posted, how do I enter in a remote hostname?
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
You get the RPC error just with mine? Did it work with Bill's?. Strange.
ASKER
@GC, that is way quicker. I made one tweak as you used the variable "computername" instead of "computeraudit".
Very fast and clean script!
Very fast and clean script!
ASKER
@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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
-Aaron
Can you share your script for review?