Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从批处理中检查windows/explorer的启动时间?_Windows_Batch File_Time_Cmd - Fatal编程技术网

如何从批处理中检查windows/explorer的启动时间?

如何从批处理中检查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

我试图在使用批处理时获取windows启动的时间,然后将当前系统时间更改为windows启动的时间,执行命令,然后更改回当前时间。我知道如何存储当前时间,然后在命令运行后使用该信息更改回其原始时间,我只是不知道如何获取Windows启动的时间,或者资源管理器,因为资源管理器是用Windows启动的

例如:

'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