{"id":224768,"date":"2021-09-01T08:04:27","date_gmt":"2021-09-01T00:04:27","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=224768"},"modified":"2021-08-20T15:04:57","modified_gmt":"2021-08-20T07:04:57","slug":"windows-query-uptime","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/windows-query-uptime.html","title":{"rendered":"\u5982\u4f55\u5728 Windows \u4e2d\u68c0\u67e5\u8ba1\u7b97\u673a\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8ba1\u7b97\u673a\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4\u662f\u6307\u7cfb\u7edf\u5728\u6ca1\u6709\u5173\u673a\u6216\u91cd\u65b0\u542f\u52a8\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\u7684\u65f6\u95f4\u3002\u8ba1\u7b97\u673a\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4\u5e2e\u52a9\u6211\u4eec\u627e\u5230\u4efb\u4f55\u7cfb\u7edf\u7684\u6700\u540e\u4e00\u6b21\u91cd\u542f\u3002\u8fd9\u5728\u8bb8\u591a\u65b9\u9762\u90fd\u6709\u5e2e\u52a9\uff0c\u4f8b\u5982\u6545\u969c\u6392\u9664\u6216\u811a\u672c\u7f16\u5199\u7b49\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba\u68c0\u67e5 Windows \u7cfb\u7edf\u7684\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4\u7684\u4e09\u79cd\u65b9\u6cd5\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u5982\u4f55\u4f7f\u7528\u4efb\u52a1\u7ba1\u7406\u5668\u68c0\u67e5 Windows \u6b63\u5e38\u8fd0\u884c\u65f6\u95f4<\/strong><\/div>\n

\u4efb\u52a1\u7ba1\u7406\u5668\u662f\u7528\u4e8e\u68c0\u67e5\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u548c\u670d\u52a1\u53ca\u5176\u8be6\u7ec6\u4fe1\u606f\u7684\u5de5\u5177\u3002\u8fd8\u53ef\u4ee5\u627e\u5230\u6709\u5173\u8d44\u6e90\u5229\u7528\u7387\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u4f8b\u5982\u8fd0\u884c\u65f6\u7684\u5185\u5b58\u548c CPU \u4f7f\u7528\u60c5\u51b5\u3002\u8fd9\u4e5f\u662f Windows \u7528\u6237\u67e5\u627e\u8ba1\u7b97\u673a\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4\u7684\u4e00\u79cd\u5feb\u901f\u4e14\u9996\u9009\u7684\u65b9\u5f0f\u3002<\/p>\n

\u6253\u5f00\u4efb\u52a1\u7ba1\u7406\u5668\uff0c\u70b9\u51fb\u6027\u80fd\uff0c\u70b9\u51fbcpu\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u201c\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4\u201d\u4e86\u3002
\n\"\"
\n\u4e0a\u56fe\u663e\u793a\u8ba1\u7b97\u673a\u5f00\u673a\u5df2\u7ecf3\u592911\u5c0f\u65f6\u4e86\u3002<\/p>\n

\u4f7f\u7528\u547d\u4ee4\u884c\u68c0\u67e5\u8ba1\u7b97\u673a\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4<\/strong><\/div>\n

\u8fd8\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u9009\u9879\u67e5\u770b Windows \u6b63\u5e38\u8fd0\u884c\u65f6\u95f4\u3002\u4e0b\u9762\u4f7f\u7528wmic<\/code>\u548csysteminfo<\/code>\u4e24\u4e2a\u547d\u4ee4\u6765\u67e5\u770bwindows\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4\u3002<\/p>\n

A. \u4f7f\u7528WMIC\u547d\u4ee4<\/strong><\/span><\/div>\n

WMIC<\/code>\uff08Windows \u7ba1\u7406\u63a5\u53e3\u547d\u4ee4\uff09\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u547d\u4ee4\u884c\u7a0b\u5e8f\uff0c\u53ef\u63d0\u4f9b\u6709\u5173\u6b63\u5728\u8fd0\u884c\u7684\u7cfb\u7edf\u4fe1\u606f\u3002\u501f\u52a9\u6b64\u547d\u4ee4\uff0c\u6211\u4eec\u53ef\u4ee5\u627e\u5230\u4e0a\u6b21\u542f\u52a8\u65f6\u95f4\u3002<\/p>\n

\r\n> wmic path Win32_OperatingSystem get LastBootUpTime\r\nLastBootUpTime\r\n20210816213830.500000+480\r\n<\/pre>\n

\"\"<\/p>\n

B. \u4f7f\u7528systeminfo\u547d\u4ee4<\/strong><\/span><\/div>\n

systeminfo<\/code> \u547d\u4ee4\u663e\u793a\u6709\u5173\u64cd\u4f5c\u7cfb\u7edf\u3001\u8ba1\u7b97\u673a\u8f6f\u4ef6\u548c\u786c\u4ef6\u7ec4\u4ef6\u7684\u8be6\u7ec6\u4fe1\u606f\u5217\u8868\u3002\u53ef\u4ee5\u7528\u5b83\u67e5\u8be2\u201c\u7cfb\u7edf\u542f\u52a8\u65f6\u95f4\u201d\u7684\u503c\uff0c\u4ee5\u83b7\u5f97\u8ba1\u7b97\u673a\u7684\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4\u3002<\/p>\n

\u5982\u679c\u7cfb\u7edf\u662f\u4e2d\u6587\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528find<\/code>\u5de5\u5177\u7b5b\u9009\u201c\u7cfb\u7edf\u542f\u52a8\u65f6\u95f4\u201d\uff1a<\/p>\n

\r\n> systeminfo | find \"\u7cfb\u7edf\u542f\u52a8\u65f6\u95f4\"\r\n\u7cfb\u7edf\u542f\u52a8\u65f6\u95f4:     2021\/8\/16, 21:38:30\r\n<\/pre>\n

\"\"
\n\u5982\u679c\u7cfb\u7edf\u662f\u82f1\u6587\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528find<\/code>\u5de5\u5177\u7b5b\u9009\u201cSystem Boot Time\u201d\uff1a<\/p>\n

\r\n> systeminfo | find \"System Boot Time\"\r\nSystem Boot Time:          1\/6\/2021, 4:34:35 PM\r\n<\/pre>\n

\"\"<\/p>\n

\u4f7f\u7528 PowerShell \u68c0\u67e5 Windows \u6b63\u5e38\u8fd0\u884c\u65f6\u95f4<\/strong><\/div>\n

\u542f\u52a8 Powershell \u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u67e5\u627e\u5f53\u524d\u7cfb\u7edf\u7684\u6700\u540e\u4e00\u6b21\u91cd\u542f\u65f6\u95f4\u3002<\/p>\n

\r\n> Get-CimInstance -ClassName Win32_OperatingSystem | select LastBootUpTime\r\n\r\nLastBootUpTime\r\n--------------\r\n2021\/8\/16 21:38:30\r\n<\/pre>\n

\"\"
\n\u6216\u8005\u4f7f\u7528\u4e0b\u9762\u547d\u4ee4\uff1a<\/p>\n

\r\n> gcim Win32_OperatingSystem|select LastBootUpTime\r\n\r\nLastBootUpTime\r\n--------------\r\n2021\/8\/16 21:38:30\r\n<\/pre>\n

\"\"
\n\u8fd8\u53ef\u4ee5\u4ee5\u5929\u6570\u3001\u5c0f\u65f6\u3001\u5206\u949f\u7684\u683c\u5f0f\u67e5\u770b\u8ba1\u7b97\u673a\u7684\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4\u3002\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u7ed3\u679c\uff1a<\/p>\n

\r\n> (Get-Date) - (gcim Win32_OperatingSystem).LastBootUpTime\r\n\r\n\r\nDays              : 3\r\nHours             : 11\r\nMinutes           : 44\r\nSeconds           : 1\r\nMilliseconds      : 927\r\nTicks             : 3014419271663\r\nTotalDays         : 3.4889111940544\r\nTotalHours        : 83.7338686573055\r\nTotalMinutes      : 5024.03211943833\r\nTotalSeconds      : 301441.9271663\r\nTotalMilliseconds : 301441927.1663\r\n<\/pre>\n

\"\"
\n\u8fd8\u53ef\u4ee5\u5c06\u4e0a\u9762\u7684\u547d\u4ee4\u8f93\u51fa\u5b58\u50a8\u5230\u53d8\u91cf\u4e2d\u3002\u8fd9\u5bf9\u4e8e\u7f16\u5199\u811a\u672c\u5f88\u6709\u5e2e\u52a9\u3002\u4ee5\u4e0b\u547d\u4ee4\u5c06\u6240\u6709\u503c\u5b58\u50a8\u5728\u201c$uptime\u201d\u53d8\u91cf\u4e2d\u3002<\/p>\n

\r\n> $uptime = (get-date) - (gcim Win32_OperatingSystem).LastBootUpTime\r\n<\/pre>\n

\"\"
\n\u63a5\u4e0b\u6765\uff0c\u4ec5\u63d0\u53d6\u7279\u5b9a\u503c\u5e76\u5c06\u5176\u6253\u5370\u5728\u5c4f\u5e55\u4e0a\u3002<\/p>\n

\r\n> Write-Output \"The Windows Uptime is : $($uptime.days) Days, $($uptime.hours) Hours and $($uptime.minutes) Minutes\"\r\nThe Windows Uptime is : 3 Days, 11 Hours and 46 Minutes\r\n<\/pre>\n

\"\"<\/p>\n

\u603b\u7ed3<\/strong><\/div>\n

\u5728\u672c\u6559\u7a0b\u4e2d\u5b66\u4e60\u4e86\u68c0\u67e5 Windows \u6b63\u5e38\u8fd0\u884c\u65f6\u95f4\u7684\u5404\u79cd\u65b9\u6cd5\u3002\u672c\u6307\u5357\u6db5\u76d6\u4e86\u4efb\u52a1\u7ba1\u7406\u5668\u3001\u547d\u4ee4\u63d0\u793a\u7b26\u548c PowerShell \u7684 3 \u79cd\u65b9\u6cd5\u6765\u83b7\u5f97\u8ba1\u7b97\u673a\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4efb\u52a1\u7ba1\u7406\u5668\u662f\u7528\u4e8e\u68c0\u67e5\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u548c\u670d\u52a1\u53ca\u5176\u8be6\u7ec6\u4fe1\u606f\u7684\u5de5\u5177\u3002\u8fd8\u53ef\u4ee5\u627e\u5230\u6709\u5173\u8d44\u6e90\u5229\u7528\u7387\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u4f8b\u5982\u8fd0\u884c\u65f6\u7684\u5185 […]<\/p>\n","protected":false},"author":309,"featured_media":224769,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-224768","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/224768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/309"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=224768"}],"version-history":[{"count":1,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/224768\/revisions"}],"predecessor-version":[{"id":224779,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/224768\/revisions\/224779"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/224769"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=224768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=224768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=224768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}