Chkdsk Batch File.

Discussion in 'Software' started by Eldon, May 18, 2018.

  1. Eldon

    Eldon Major Geek Extraordinaire

    I have made another batch file - this time to run Check Disk (chkdsk) without any user input and to save the scan results in a text file.

    @GermanOne, I have taken the liberty to add your code to the batch file to check the Windows version, check for pending Windows updates, and to run the batch script elevated.
    Kindly let me know if this is OK (I will credit the code to you).

    I will appreciate if members would test this batch file.
    I have tested it in Windows 7 & 8 - it will not run in Windows Vista and earlier.

    Note:
    There's no need to right-click the batch file and click Run as administrator - the UAC prompt will automatically appear.
    The batch file runs in read-only mode - it will scan for logical file system errors but not repair them.
     

    Attached Files:

    baklogic likes this.
  2. Anon-469e6fb48c

    Anon-469e6fb48c Anonymized

    It keeps saying Maximum setlocal recursion level reached.

    I don't think it's suppose to say that.

    Windows 7
     
  3. Anon-469e6fb48c

    Anon-469e6fb48c Anonymized

    I think there is an issue with the code.

    @if (@a)==(@b) @end /* :: Valid line in both Batch and JScript to begin a JScript multi-line comment.

    @echo off &setlocal EnableExtensions DisableDelayedExpansion
    :: Check the Windows version.
    for /f "tokens=2 delims=[]" %%i in ('ver') do for /f "tokens=2,3 delims=. " %%j in ("%%i") do set /a "ver=%%j * 100 + %%k"
    if %ver% lss 601 (
    echo The script does not support versions prior to Windows 7.
    pause
    exit /b
    )
    :: File repair will abort if Windows updates are pending. Prompt the user to install updates first.
    if exist "%windir%\winsxs\pending.xml" (
    echo A Windows update is pending.
    echo Please install it first and reboot your computer.
    pause
    exit /b
    )
    :: Check if the script was run elevated. If not run the code again as JScript to invoke the UAC prompt and run as Administrator.
    >nul 2>&1 net session || (
    cscript //nologo //e:jscript "%~fs0" "%~f0"
    exit /b
    )
    :: Run Check Disk (chkdsk)
    chkdsk
    :: Filter the Event Viewer log & save the results to the Desktop
    Powershell -Command "& "Get-winevent -FilterHashTable @{logname='Application'; id='26212'}^|?{$_.providername -match 'Chkdsk'} ^| fl timecreated, message ^| out-file '%userprofile%\Desktop\chkdsk.txt'"
    start Notepad "%userprofile%\Desktop\chkdsk.txt%"
    exit /b
    :: JScript:
    */ WScript.CreateObject('Shell.Application').ShellExecute('cmd.exe', '/c "' + WScript.Arguments(0) + '"', '', 'runas', 1);
     
    baklogic likes this.
  4. GermanOne

    GermanOne Guest

    Of course. Do whatever you want with the code.

    Rename the file (e.g. CHCKDSK_.but) and try again.

    @Eldon never name a batch script the same as a command that you call in the code. The script might run itself recursively in an infinite loop. If you still want to keep the name then add the extension to the call of the utility
    Code:
    :: Run Check Disk (chkdsk)
    chkdsk.exe
    Steffen
     
    baklogic and Eldon like this.
  5. Anon-469e6fb48c

    Anon-469e6fb48c Anonymized

    Ok now it works renaming it.

    e.g. CHCKDSK_.but
     
  6. GermanOne

    GermanOne Guest

    LOL Typo. The extension still needs to be .bat ... Obviously you did it right.
     
  7. Anon-469e6fb48c

    Anon-469e6fb48c Anonymized


    lol this is what i put e.g. CHCKDSK_.but'.bat
     
  8. Anon-469e6fb48c

    Anon-469e6fb48c Anonymized

    This is to verify it works.



    TimeCreated : 5/18/2018 7:48:12 PM
    Message : Chkdsk was executed in read-only mode on a volume snapshot.

    Checking file system on C:
    The type of the file system is NTFS.

    WARNING! F parameter not specified.
    Running CHKDSK in read-only mode.

    CHKDSK is verifying files (stage 1 of 3)...
    Cleaning up instance tags for file 0xc757.
    236800 file records processed.

    File verification completed.
    450 large file records processed.

    0 bad file records processed.

    4 EA records processed.

    44 reparse records processed.

    CHKDSK is verifying indexes (stage 2 of 3)...
    285880 index entries processed.

    Index verification completed.
    0 unindexed files scanned.

    0 unindexed files recovered.

    CHKDSK is verifying security descriptors (stage 3 of 3)...
    236800 file SDs/SIDs processed.

    Cleaning up 245 unused index entries from index $SII of file 0x9.
    Cleaning up 245 unused index entries from index $SDH of file 0x9.
    Cleaning up 245 unused security descriptors.
    Security descriptor verification completed.
    24541 data files processed.

    CHKDSK is verifying Usn Journal...
    35496824 USN bytes processed.

    Usn Journal verification completed.
    Windows has checked the file system and found no problems.

    234326015 KB total disk space.
    99078740 KB in 135985 files.
    73028 KB in 24542 indexes.
    0 KB in bad sectors.
    346023 KB in use by the system.
    65536 KB occupied by the log file.
    134828224 KB available on disk.

    4096 bytes in each allocation unit.
    58581503 total allocation units on disk.
    33707056 allocation units available on disk.


    TimeCreated : 5/18/2018 7:41:37 PM
    Message : Chkdsk was executed in read-only mode on a volume snapshot.

    Checking file system on C:
    The type of the file system is NTFS.

    WARNING! F parameter not specified.
    Running CHKDSK in read-only mode.

    CHKDSK is verifying files (stage 1 of 3)...
    Cleaning up instance tags for file 0xc757.
    236800 file records processed.

    File verification completed.
    450 large file records processed.

    0 bad file records processed.

    4 EA records processed.

    44 reparse records processed.

    CHKDSK is verifying indexes (stage 2 of 3)...
    285880 index entries processed.

    Index verification completed.
    0 unindexed files scanned.

    0 unindexed files recovered.

    CHKDSK is verifying security descriptors (stage 3 of 3)...
    236800 file SDs/SIDs processed.

    Cleaning up 245 unused index entries from index $SII of file 0x9.
    Cleaning up 245 unused index entries from index $SDH of file 0x9.
    Cleaning up 245 unused security descriptors.
    Security descriptor verification completed.
    24541 data files processed.

    CHKDSK is verifying Usn Journal...
    35450352 USN bytes processed.

    Usn Journal verification completed.
    Windows has checked the file system and found no problems.

    234326015 KB total disk space.
    98862104 KB in 135982 files.
    73028 KB in 24542 indexes.
    0 KB in bad sectors.
    346023 KB in use by the system.
    65536 KB occupied by the log file.
    135044860 KB available on disk.

    4096 bytes in each allocation unit.
    58581503 total allocation units on disk.
    33761215 allocation units available on disk.
     
    Eldon likes this.
  9. GermanOne

    GermanOne Guest

    Yes that's the expected output.
    0 bad file records processed.
    and
    0 KB in bad sectors.
    state that no defects were found.
     
  10. Eldon

    Eldon Major Geek Extraordinaire

    Thanks.
    FWIW I just ran the script again without issues.
    But, I will rename it and also check the Windows 8 PC later today.
     
  11. GermanOne

    GermanOne Guest

    If the script was run elevated then the working directory was automatically changed to C:\Windows\System32 which means that the script doesn't see its own file. In that case it will work without problems. I guess that while e coyote disabled the UAC prompt (definitely not recommented ;)) on his machine which made that the working directory kept still the same.
     
    Eldon likes this.
  12. Eldon

    Eldon Major Geek Extraordinaire

    Now that explains it.

    Here's the renamed batch file.
     

    Attached Files:

  13. Anon-469e6fb48c

    Anon-469e6fb48c Anonymized

    Yes i do disable my UAC when i do a fresh install of windows.Be cause it kinda annoys me.
     
  14. GermanOne

    GermanOne Guest

    Some minor corrections
    Code:
    @if (@a)==(@b) @end /* :: Valid line in both Batch and JScript to begin a JScript multi-line comment.
    
    @echo off &setlocal EnableExtensions DisableDelayedExpansion
    :: Check the Windows version.
    for /f "tokens=2 delims=[]" %%i in ('ver') do for /f "tokens=2,3 delims=. " %%j in ("%%i") do set /a "ver=%%j * 100 + %%k"
    if %ver% lss 601 (
      echo The script does not support versions prior to Windows 7.
      pause
      exit /b
    )
    :: File repair will abort if Windows updates are pending. Prompt the user to install updates first.
    if exist "%windir%\winsxs\pending.xml" (
      echo A Windows update is pending.
      echo Please install it first and reboot your computer.
      pause
      exit /b
    )
    :: Check if the script was run elevated. If not run the code again as JScript to invoke the UAC prompt and run as Administrator.
    >nul 2>&1 net session || (
      cscript //nologo //e:jscript "%~fs0" "%~f0"
      exit /b
    )
    :: Run Check Disk (chkdsk)
    chkdsk.exe
    :: Filter the Event Viewer log & save the results to the Desktop
    Powershell -NoProfile -ExecutionPolicy Bypass -Command "& {Get-winevent -FilterHashTable @{logname='Application'; id='26212'} | ?{$_.providername -match 'Chkdsk'} | fl timecreated, message | out-file '%userprofile%\Desktop\chkdsk.txt'}"
    start Notepad "%userprofile%\Desktop\chkdsk.txt"
    exit /b
    :: JScript:
    */ WScript.CreateObject('Shell.Application').ShellExecute('cmd.exe', '/c "' + WScript.Arguments(0) + '"', '', 'runas', 1);
    Steffen
     
  15. satrow

    satrow Major Geek Extraordinaire

  16. baklogic

    baklogic The Tinkerer

    I tried Eldon's file in W8.1, and I had smart screen on- just told it to allow, and it worked perfectly. I did run it in administrator mode.
    I then tried GermanOne's edited version, called it CHKDSKEW2.bat
    It worked flawlessly without a problem- Great job Eldon and GermanOne.
    F parameter not stated, would that push it to make a fix (probably on re-start ?)
     
    Eldon likes this.
  17. baklogic

    baklogic The Tinkerer

    Tested in Windows 10- both versions work O.K
     
    Eldon likes this.
  18. GermanOne

    GermanOne Guest

    @satrow
    Not sure what Script Defender does to make the script restart repeatedly nor for what reason it blocks its execution. Try to run that code. I modified it in a way that the JScript portion will be called only once.
    Code:
    @if (@a)==(@b) @end /* :: Valid line in both Batch and JScript to begin a JScript multi-line comment.
    
    @echo off &setlocal EnableExtensions DisableDelayedExpansion
    :: Check the Windows version.
    for /f "tokens=2 delims=[]" %%i in ('ver') do for /f "tokens=2,3 delims=. " %%j in ("%%i") do set /a "ver=%%j * 100 + %%k"
    if %ver% lss 601 (
      echo The script does not support versions prior to Windows 7.
      pause
      exit /b
    )
    :: File repair will abort if Windows updates are pending. Prompt the user to install updates first.
    if exist "%windir%\winsxs\pending.xml" (
      echo A Windows update is pending.
      echo Please install it first and reboot your computer.
      pause
      exit /b
    )
    :: Check if the script was run elevated. If not run the code again as JScript to invoke the UAC prompt and run as Administrator.
    >nul 2>&1 net session || (
      if "%~1"=="" cscript //nologo //e:jscript "%~fs0" "%~f0"
      exit /b
    )
    :: Run Check Disk (chkdsk)
    chkdsk.exe
    :: Filter the Event Viewer log & save the results to the Desktop
    Powershell -NoProfile -ExecutionPolicy Bypass -Command "& {Get-winevent -FilterHashTable @{logname='Application'; id='26212'} | ?{$_.providername -match 'Chkdsk'} | fl timecreated, message | out-file '%userprofile%\Desktop\chkdsk.txt'}"
    start Notepad "%userprofile%\Desktop\chkdsk.txt"
    exit /b
    :: JScript:
    */ WScript.CreateObject('Shell.Application').ShellExecute('cmd.exe', '/c ""' + WScript.Arguments(0) + '" X"', '', 'runas', 1);
    
     
  19. satrow

    satrow Major Geek Extraordinaire

    Thanks very much.

    Script Defender intercepts certain script types (.VBS,.VBE,.JS,.JSE,.HTA,.WSF,.WSH,.SHS,.SHB), now that I've rebooted to recover from the manic cmd windows, I'll remove the intercepts and try it again.
    ...
    Okay, better result, ran and closed inside 1 second, no new txt file on the Desktop; so there's *something else* here that's triggering a fail - my W7 is nowhere near a default install, don't waste any more time on coding a debug version just for me :)
     
    Eldon likes this.
  20. Eldon

    Eldon Major Geek Extraordinaire

    Thank you all for testing the batch file! :)
     
    satrow likes this.
  21. GermanOne

    GermanOne Guest

    @Eldon Some thoughts
    • I don't think it's required to install pending updates first (that was something I included for SFC because SFC won't run otherwise). If the user suspect a defect on the disk then it would be rather disadvantageous to have additional writing operations on the disk.
    • You could add a user interaction (e.g. a CHOICE command) to add option /F if the user also wants to repair found defects.
    • What about supporting other disks but C:?
    • Out of satrow's observations I think you may add the additional check in your SFC script, too. The technique is simple. I just pass an argument to the script (X in this case) if it was run from the JScript portion. In the Batch portion I only run the JScript if no argument was passed that is, the script was run via double click.
    Steffen
     
    Last edited by a moderator: May 20, 2018
    satrow likes this.
  22. Eldon

    Eldon Major Geek Extraordinaire

    @GermanOne Thank you for your invaluable input!

    I can remove that part of the script. However, chkdsk without the /F or /R switches run in read-only mode.
    I have already done that and will upload the latest version asap.
    I need help with this...
    Scripting is very new to me and unfortunately life and work keep getting in the way. And at the same time I'm looking at PowerShell scripting.
     
  23. GermanOne

    GermanOne Guest

    No problem.
    NOTE:
    This example only displays the command line using ECHO. You can safely test without performing the actual command.
    Code:
    @echo off &setlocal EnableExtensions DisableDelayedExpansion
    set /a "timeout=10"
    
    :: user interaction to get the drive to be checked (defaults to the system drive after %timeout% seconds)
    setlocal EnableDelayedExpansion
    for /f "delims=:" %%i in ("%SystemDrive%") do set "sysdrive=%%i"
    set "drives="
    for /f %%i in ('mountvol^|findstr /ric:"\<[A-Z]:\\\>"') do for /f "delims=:" %%j in ("%%i") do set "drives=!drives!%%j"
    echo What disk do you want to be checked?
    echo Enter one out of %drives%
    choice /c %drives% /n /t %timeout% /d %sysdrive% /m "(defaults to %sysdrive% after %timeout% seconds): "
    set /a "idx=%errorlevel% - 1"
    cls
    set "drive=!drives:~%idx%,1!:"
    endlocal &set "drive=%drive%"
    
    :: user interaction to get the options for chkdsk (defaults to no additional options after %timeout% seconds)
    echo Do you want to perform an automatic fixing if possible? [YN]
    choice /c YN /n /t %timeout% /d N /m "(defaults to N after %timeout% seconds): "
    if %errorlevel% equ 1 (set "opt=/F /R") else set "opt="
    cls
    
    :: resulting command line:
    ECHO chkdsk.exe %drive% %opt%
    PAUSE
    
     
  24. Eldon

    Eldon Major Geek Extraordinaire

    Thank you.
    You put in so much work on this batch script.
     
  25. GermanOne

    GermanOne Guest

    Don't worry about that. I have a bunch of script snippets collected over the years. Most of the things are only c/p from old scripts ;)

    Now we have an additional task though. If the drive chosen was the system drive and fixing shall be applied then the operation will be applied at the next reboot. I'll try to figure out
    • how the user decided
    • how to write and execute a script that collects the data for the text file after the restart in that case

    FWIW I forgot to answer ...
    My point was that you force the user to install a pending update first. That will cause the write operations on the disk ;)

    Steffen
     
  26. GermanOne

    GermanOne Guest

    Okay I think that should work out:
    Code:
    @if (@a)==(@b) @end /* :: Valid line in both Batch and JScript to begin a JScript multi-line comment.
    
    @echo off &setlocal EnableExtensions DisableDelayedExpansion
    :: Check the Windows version.
    for /f "tokens=2 delims=[]" %%i in ('ver') do for /f "tokens=2,3 delims=. " %%j in ("%%i") do set /a "ver=%%j * 100 + %%k"
    if %ver% lss 601 (
      echo The script does not support versions prior to Windows 7.
      pause
      exit /b
    )
    :: Check if the script was run elevated. If not run the code again as JScript to invoke the UAC prompt and run as Administrator.
    >nul 2>&1 net session || (
      if "%~1"=="" cscript //nologo //e:jscript "%~fs0" "%~f0"
      exit /b
    )
    set /a "timeout=10"
    :: user interaction to get the drive to be checked (defaults to the system drive after %timeout% seconds)
    setlocal EnableDelayedExpansion
    for /f "delims=:" %%i in ("%SystemDrive%") do set "sysdrive=%%i"
    set "drives="
    for /f %%i in ('mountvol^|findstr /ric:"\<[A-Z]:\\\>"') do for /f "delims=:" %%j in ("%%i") do set "drives=!drives!%%j"
    echo What disk do you want to be checked?
    echo Enter one out of [%drives%]
    choice /c %drives% /n /t %timeout% /d %sysdrive% /m "(defaults to %sysdrive% after %timeout% seconds): "
    set /a "idx=%errorlevel% - 1"
    cls
    set "drive=!drives:~%idx%,1!:"
    endlocal &set "drive=%drive%"
    :: user interaction to get the options for chkdsk (defaults to no additional options after %timeout% seconds)
    echo Do you want to perform an automatic fixing if possible? [YN]
    choice /c YN /n /t %timeout% /d N /m "(defaults to N after %timeout% seconds): "
    if %errorlevel% equ 1 (set "opt=/F /R") else set "opt="
    cls
    :: Run Check Disk (chkdsk)
    chkdsk.exe %drive% %opt%
    :: if chkdsk was scheduled get the log after the reboot
    if %errorlevel% equ 3 (
      if /i "%drive%" equ "%SystemDrive%" chkntfs %drive% | >nul findstr /ric:"\<CHKDSK\>" && (
        >"%temp%\getlog.bat" (
          echo @echo off
          echo Powershell -NoProfile -ExecutionPolicy Bypass -Command "& {Get-winevent -FilterHashTable @{logname='Application'; id='1001'} | ?{$_.providername -match 'Wininit'} | fl timecreated, message | out-file '%userprofile%\Desktop\chkdsk.txt'}"
          echo start Notepad "%userprofile%\Desktop\chkdsk.txt"
          echo del "%%~fs0"^&exit
        )
        >nul reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v "DisableLocalUserRunOnce" /t REG_DWORD /d 0 /f
        >nul reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v "getchkdsklog{winit}" /t REG_SZ /d "\"%comspec%\" /c \"%temp%\getlog.bat\"" /f
        cls
        setlocal EnableDelayedExpansion
        choice /c YN /n /t %timeout% /d N /m "Do you want to reboot now? [YN] "
        if !errorlevel! equ 1 shutdown /r /t 0
        endlocal
      )
      exit /b
    )
    :: Filter the Event Viewer log & save the results to the Desktop
    Powershell -NoProfile -ExecutionPolicy Bypass -Command "& {Get-winevent -FilterHashTable @{logname='Application'; id='26212'} | ?{$_.providername -match 'Chkdsk'} | fl timecreated, message | out-file '%userprofile%\Desktop\chkdsk.txt'}"
    start Notepad "%userprofile%\Desktop\chkdsk.txt"
    exit /b
    :: JScript:
    */ WScript.CreateObject('Shell.Application').ShellExecute('cmd.exe', '/c ""' + WScript.Arguments(0) + '" X"', '', 'runas', 1);
    
    Using CHKNTFS we can determine if CHKDSK was scheduled. In that case a temporary batch file will be created that runs using a RunOnce registry entry after the reboot.

    Steffen
     
    Last edited by a moderator: May 20, 2018
    Eldon likes this.
  27. Eldon

    Eldon Major Geek Extraordinaire

    Hi everyone,
    Sorry for seemingly abandoning this thread.
    I have a chronic infection in my left eye and optic neuritis in my right eye and it's extremely difficult to concentrate on script files.

    Back to business...
    The only issue I have found is Windows 8 and newer uses the Evevt ID 26226 whereas Windows 7 uses 26212. I cannot get the script to 'look' at either or both.
    Any suggestions?
     
  28. GermanOne

    GermanOne Guest

    Hope you're doing well again, Eldon!

    The documentation states ...
    ... which tells us 2 things
    1. The type of a single ID is Int32. That means the surrounding single quotes in the script above are actually wrong because they make the ID a string. Fortunately an implicit type cast seems to be in place to make it work. However we should leave them out.
    2. The brackets indicate that the ID is not just a single ID. Its taken as an array of IDs. We can simply write a comma-separated list of IDs in the script.
    Code:
    @if (@a)==(@b) @end /* :: Valid line in both Batch and JScript to begin a JScript multi-line comment.
    
    @echo off &setlocal EnableExtensions DisableDelayedExpansion
    :: Check the Windows version.
    for /f "tokens=2 delims=[]" %%i in ('ver') do for /f "tokens=2,3 delims=. " %%j in ("%%i") do set /a "ver=%%j * 100 + %%k"
    if %ver% lss 601 (
      echo The script does not support versions prior to Windows 7.
      pause
      exit /b
    )
    :: Check if the script was run elevated. If not run the code again as JScript to invoke the UAC prompt and run as Administrator.
    >nul 2>&1 net session || (
      if "%~1"=="" cscript //nologo //e:jscript "%~fs0" "%~f0"
      exit /b
    )
    set /a "timeout=10"
    :: user interaction to get the drive to be checked (defaults to the system drive after %timeout% seconds)
    setlocal EnableDelayedExpansion
    for /f "delims=:" %%i in ("%SystemDrive%") do set "sysdrive=%%i"
    set "drives="
    for /f %%i in ('mountvol^|findstr /ric:"\<[A-Z]:\\\>"') do for /f "delims=:" %%j in ("%%i") do set "drives=!drives!%%j"
    echo What disk do you want to be checked?
    echo Enter one out of [%drives%]
    choice /c %drives% /n /t %timeout% /d %sysdrive% /m "(defaults to %sysdrive% after %timeout% seconds): "
    set /a "idx=%errorlevel% - 1"
    cls
    set "drive=!drives:~%idx%,1!:"
    endlocal &set "drive=%drive%"
    :: user interaction to get the options for chkdsk (defaults to no additional options after %timeout% seconds)
    echo Do you want to perform an automatic fixing if possible? [YN]
    choice /c YN /n /t %timeout% /d N /m "(defaults to N after %timeout% seconds): "
    if %errorlevel% equ 1 (set "opt=/F /R") else set "opt="
    cls
    :: Run Check Disk (chkdsk)
    chkdsk.exe %drive% %opt%
    :: if chkdsk was scheduled get the log after the reboot
    if %errorlevel% equ 3 (
      if /i "%drive%" equ "%SystemDrive%" chkntfs %drive% | >nul findstr /ric:"\<CHKDSK\>" && (
        >"%temp%\getlog.bat" (
          echo @echo off
          echo Powershell -NoProfile -ExecutionPolicy Bypass -Command "& {Get-winevent -FilterHashTable @{logname='Application'; id=1001} | ?{$_.providername -match 'Wininit'} | fl timecreated, message | out-file '%userprofile%\Desktop\chkdsk.txt'}"
          echo start Notepad "%userprofile%\Desktop\chkdsk.txt"
          echo del "%%~fs0"^&exit
        )
        >nul reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v "DisableLocalUserRunOnce" /t REG_DWORD /d 0 /f
        >nul reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v "getchkdsklog{winit}" /t REG_SZ /d "\"%comspec%\" /c \"%temp%\getlog.bat\"" /f
        cls
        setlocal EnableDelayedExpansion
        choice /c YN /n /t %timeout% /d N /m "Do you want to reboot now? [YN] "
        if !errorlevel! equ 1 shutdown /r /t 0
        endlocal
      )
      exit /b
    )
    :: Filter the Event Viewer log & save the results to the Desktop
    Powershell -NoProfile -ExecutionPolicy Bypass -Command "& {Get-winevent -FilterHashTable @{logname='Application'; id=26226,26212} | ?{$_.providername -match 'Chkdsk'} | fl timecreated, message | out-file '%userprofile%\Desktop\chkdsk.txt'}"
    start Notepad "%userprofile%\Desktop\chkdsk.txt"
    exit /b
    :: JScript:
    */ WScript.CreateObject('Shell.Application').ShellExecute('cmd.exe', '/c ""' + WScript.Arguments(0) + '" X"', '', 'runas', 1);
    
    BTW: I tried the code on Win10 where the ID is 26212 again. Seems that Win8 is rather an exception :confused:
     
    Last edited by a moderator: Jul 15, 2018
    Eldon likes this.
  29. Eldon

    Eldon Major Geek Extraordinaire

    Thank you GermanOne.
    Those darn single quotes! :mad:
    I'm going to lay the blame at Microsoft's door...
    In Windows 10 it was 26226 and now it's changed back to 26212.
     
  30. GermanOne

    GermanOne Guest

    Google also told me something about 26214 and 26228 :eek: However I didn't find any explanation why and in which case the ID is getting changed.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds