gpt4 book ai didi

powershell - 如何获得在引导时运行的 CHKDSK 的结果?

转载 作者:行者123 更新时间:2023-12-03 00:36:16 25 4
gpt4 key购买 nike

有问题

CHKDSK ran when my machine rebooted, and displayed some stuff. Problem is I have no idea what it displayed, since it then proceeded to reboot the machine when it was done. How do I get it to stop, pause or otherwise let me see what it did ?

chkdsk cannot run because the volume is in use by another process mean ?, CHKDSK needs exclusive access to the disk it’s checking if it’s been instructed to attempt fixes or repairs. If that disk is your Windows drive (C:), CHKDSK can’t have exclusive access, because Windows is using that drive simply to run your system.

enter image description here

当我们重新启动时,在加载 Windows 之前执行 CHKDSK。

enter image description here

CHKDSK 像往常一样运行,当它完成时,它会重新启动系统——当然,这会导致屏幕上可能显示的任何进度或结果消失。

为了创建一个有用的工具来维护我的硬盘驱动器以检查、修复和修复它们的错误。

我做了这批

@echo off
Title Check Disk drives for errors and fix them by Hackoo 2016
mode con cols=67 lines=5 & Color 0A
:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
set "TmpLog=%Tmp%\TmpLog.txt"
set "Log=%~dp0%computername%_%~n0.txt"
If Exist "%TmpLog%" Del "%TmpLog%"
If exist "%Log%" Del "%Log%"
REM --> Check for permissions
Reg query "HKU\S-1-5-19\Environment" >nul 2>&1
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
Echo.
ECHO **************************************
ECHO Running Admin shell... Please wait...
ECHO **************************************

goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B

:gotAdmin
::::::::::::::::::::::::::::
:: START ::
::::::::::::::::::::::::::::
( Echo Scan started @ & Date /T & Time /T & echo ************************ ) > "%TmpLog%"
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=2" %%i in ('wmic logicaldisk where "drivetype=3" ^|find /i ":"') do (
set "fix=%%i"
Call :Affich !fix!
(
echo !fix! Drive
echo ************************
echo(
(echo O
echo Y) | CHKDSK !fix! /f
echo(
echo ************************
)>> "%TmpLog%"
)
EndLocal
Goto Question
Exit /b

:Question
( echo Scan finished @ & Date /T & Time /T & echo ************************ )>> "%TmpLog%"
CMD /U /C Type "%TmpLog%" > "%Log%"
If Exist "%TmpLog%" Del "%TmpLog%"
(
echo Answ = MsgBox("Did you want to reboot the computer to complete the scanning ?",VbYesNo+VbQuestion,"Reboot the computer to check hard disk drives for errors by Hackoo"^)
echo If Answ = VbYes then
echo wscript.Quit(0^)
echo Else
echo wscript.Quit(1^)
echo End If
)>"%tmp%\%~n0.vbs"

Cscript /nologo "%tmp%\%~n0.vbs"
IF "%errorlevel%" EQU "1" (start "" "%Log%" & Exit ) else (goto Shutdown)

:Shutdown
echo(
cls
echo(
echo Save your work - Reboot of your computer in 20 seconds
echo(
echo Enregistrer vos documents - Redemarrage du PC dans 20 seconds
Shutdown.exe /r /t 20 /c "Enregistrer vos documents - Redemarrage du PC dans 20 secondes"
start "" %Log%
pause>nul
exit /b

:Affich
Cls
echo(
echo ***********************************
Echo Please wait a while Scanning "%~1"
echo ***********************************
Timeout /T 2 /nobreak>nul
exit /b

所以,我的问题是:我如何通过批处理或 powershell 获取启动时运行的 CHKDSK 的结果?

最佳答案

信息为recorded in the eventlog .您应该能够像这样获取它(使用 PowerShell):

Get-EventLog -LogName Application -Source Wininit |
Where-Object { $_.Message -like '*checking file system*' } |
Sort-Object TimeGenerated -Descending |
Select-Object -First 1 -Expand Message

关于powershell - 如何获得在引导时运行的 CHKDSK 的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38504689/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com