[SOLVED] chkdsk does not work when run from a BAT file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
DOSadnie
Posts: 143
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

[SOLVED] chkdsk does not work when run from a BAT file

#1 Post by DOSadnie » 15 Apr 2023 16:53

If I run this from CMD

Code: Select all

chkdsk T: /F /scan /perf
it works. But when I put it in a BAT file in execute it, even as an Administrator, it does nothing aside from flashing CMD window

I also tried reducing it to basic

Code: Select all

chkdsk T:
but still does not run it


Why does it not work?
Last edited by DOSadnie on 28 May 2023 09:32, edited 2 times in total.

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: chkdsk does not work when run from a BAT file

#2 Post by ShadowThief » 15 Apr 2023 17:50

There shouldn't be any problem. Open a command prompt and run the script from there instead of double-clicking it so that you can see what the error is.

DOSadnie
Posts: 143
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

Re: chkdsk does not work when run from a BAT file

#3 Post by DOSadnie » 24 Apr 2023 15:17

This is what happens

Code: Select all

C:\>test.bat

C:\>■
'■' is not recognized as an internal or external command,
operable program or batch file.

C:\>
Where thas this ■ sign comes from?

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: chkdsk does not work when run from a BAT file

#4 Post by ShadowThief » 24 Apr 2023 16:48

That's a result of you saving the file with the wrong encoding. Your batch script must be saved as ANSI or else it will not work correctly.

DOSadnie
Posts: 143
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

Re: chkdsk does not work when run from a BAT file

#5 Post by DOSadnie » 28 May 2023 09:11

That checks out, thank you

[Also saving BAT with UTF-8 encoding allows for successful running of it]

Post Reply