如何从批处理中检查windows/explorer的启动时间?
我试图在使用批处理时获取windows启动的时间,然后将当前系统时间更改为windows启动的时间,执行命令,然后更改回当前时间。我知道如何存储当前时间,然后在命令运行后使用该信息更改回其原始时间,我只是不知道如何获取Windows启动的时间,或者资源管理器,因为资源管理器是用Windows启动的 例如:如何从批处理中检查windows/explorer的启动时间?,windows,batch-file,time,cmd,Windows,Batch File,Time,Cmd,我试图在使用批处理时获取windows启动的时间,然后将当前系统时间更改为windows启动的时间,执行命令,然后更改回当前时间。我知道如何存储当前时间,然后在命令运行后使用该信息更改回其原始时间,我只是不知道如何获取Windows启动的时间,或者资源管理器,因为资源管理器是用Windows启动的 例如: 'Storing the current system time so we can change back to it at the end. FOR /F "tokens=*" %%i I
'Storing the current system time so we can change back to it at the end.
FOR /F "tokens=*" %%i IN ('time /t') DO SET CurrentTime=%%i
'Change System time to when Windows booted [Not sure how to do this part]
time %WindowsBootTime%
'Run Commands
'Now change back to it's original time.
time %CurrentTime%
我正在尝试获取windows启动的时间
使用以下批处理文件(GetBootTime.cmd)
示例输出:
> GetBootTime.cmd
2016-12-20 23:49
进一步阅读
- -对于所有与Windows命令行相关的内容都是一个很好的参考
- -根据另一个命令的结果循环命令
- -Windows Management Instrumentation命令
wmic os get LastBootUpTime
重设信息。使用for/f
检索它,并使用子字符串操作拆分时间戳(请参见set/?
),以使时间适应您的区域设置时间格式。您还可以从SYSTEMINFO获取系统启动时间<代码>系统信息|查找“系统启动”。同样,您可以使用FOR/F
将输出转换为变量。systeminfo
是sloow。它的输出是特定于语言的。在我的系统上,我必须找到“Systemstartzeit”
> GetBootTime.cmd
2016-12-20 23:49