So, is there a Batch command that changes the text in the "Type" column in explorer for an .exe.

for example, .bat files are known as "Windows Batch File" in the type. I want to make a .disk files Type "Bulk Data Storage File", using Batch.

Is there a way?


To add a new extension to "HKEY_CLASSES_ROOT" you will need to run reg.exe with elevated rights.
It is the (default) value to set with the /ve switch and /t REG_SZ

reg.exe add "HKEY_CLASSES_ROOT\.disk" /ve /t REG_SZ  /d "Bulk Data Storage File"

If you want to change a present value append /f force

You will need to close/reopen explorer windows to take this into effect.

enter image description here

The following batch will elevate itself and ask for confirmation if the value exists - displaying old/new contents.

:: Q:\Test\2018\06\16\SU_1331760.cmd
@Echo off& setlocal EnableExtensions DisableDelayedExpansion
:: elevate if neccessary
net file 1>nul 2>&1 || (powershell -ex unrestricted -Command ^
"Start-Process -Verb RunAs -FilePath '%comspec%' -ArgumentList '/c %~f0 %*'"
  goto :eof)
:: Put code here that needs elevation

Set "Dat=Bulk Data Storage File"
Set "Typ=REG_SZ"
Set "OLD="

:: reed present value, and ask for confirmation
for /f "tokens=1,2*" %%A in (
'REG QUERY "%Key%" /VE ^|find /I "REG_SZ" '
) Do Set "OLD=%%C"
If defined OLD (
    Echo do you want to replace:
    Echo Old:%OLD%
    ECHO New:%Dat%
    If errorlevel 2 exit /B 1
Echo REG ADD "%Key%" /ve /t %Typ%  /d "%Dat%" /f
     REG ADD "%Key%" /ve /t %Typ%  /d "%Dat%" /f
  • Is it necessary to add powershell? The elevated per issuing can also be checked with %errorlevel%. – Biswapriyo Jun 16 '18 at 11:51
  • The powershell part doesn't test elevation, but restarts the batch elevated. – LotPings Jun 16 '18 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.