289: Automate Shader Cleaning

TechLevel01W

Rebuilding the shader cache of the simulator helps fix problems suddenly coming up without a proper cause.   The reasons explained in my Post 58: Rebuild FSX Shader Cache for FSX.  It is applicable to P3D as well.

There are friends asking if it is possible to automate the deletion process right before the running of FSX or P3D, when needed.

Surely it is possible.   We can create a batch file called ShaderCleanerFSX.bat for FSX or ShaderCleanerP3D.bat for P3D, for example, using the scripts below.

Or simply click on either image to download both pre-written scripts for FSX and P3D.

For FSX
ShaderCleanerFSX.bat

ShaderCleanerFSX

For P3D
ShaderCleanerP3D.bat

ShaderCleanerP3D

NOTE
the download files are in text format and named

ShaderCleanerFSX.bat.txt   &
ShaderCleanerP3D.bat.txt

This is done so on purpose to prevent accidental running of the files before the changes made for the correct location of fsx.exe or Prepar3D.exe.

After the changes and savings of the files, rename the files as follows:

ShaderCleanerFSX.bat.txt  –>  ShaderCleanerFSX.bat
ShaderCleanerP3D.bat.txt  –>  ShaderCleanerP3D.bat

This will turn them into runnable batch files, which, when needed, will delete the Shader Cache folder right before the loading of the simulator.

 

 

Advertisements

14 thoughts on “289: Automate Shader Cleaning

  1. Hi Tom

    Just came across this after the need to delete shaders in FSX, works great, thanks!

    Now that I use P3Dv3 too I thought I’d try this tweak with this sim as well after changing what i think the important text, I’m renaming it from .txt to just .bat once finished but its still not launching as my FSX shader bat file does?? I used to do batch files myself back in my DOS 6 days days but mostly forgotten the art of it now :)

    This is my P3Dv3 batch file to give shader removal option …

    @echo off
    echo.
    echo ==========================
    echo Clean Shaders Cache before
    echo Loading P3D ?
    echo ==========================
    echo.
    choice /C YN
    if errorlevel 2 goto sim
    if errorlevel 1 goto cleanCache
    :cleanCache
    %systemdrive%
    cd %LOCALAPPDATA%\Lockheed Martin\Prepar3D v3
    rd Shaders /s /q
    rd Shaders10 /s /q
    goto sim
    :sim
    cd /d “I:\Lockheed Martin\Prepar3D v3\” start Prepar3D.exe
    exit

    Hope you can help

    Thanks

    Like

  2. Hi Tom!

    Thanks to you for your really great hints and tweaks. I’ve tried this and it works perfectly well on my system.
    For all the lazy guys like me :-): this is the bat file I’ve edited making the ShaderCleaner doing its job in automatic- mode (automatic cleaning of shader cache, without the choice Y/N) and it works reliable.

    @echo off
    echo.
    echo ==========================
    echo Clean Shaders Cache before
    echo Loading FSX ?
    echo ==========================
    echo.
    :cleanCache
    %systemdrive%
    cd %LOCALAPPDATA%\Microsoft\FSX
    rd Shaders /s /q
    rd Shaders10 /s /q
    goto sim
    :sim
    cd /d “F:\Microsoft Flight Simulator X” —–> “F” is named for MY SSD Drive
    start fsx.exe
    exit

    Best regards to you,
    Klaus from Germany

    Like

    1. Hi Klaus, You could further reduce it as follows if you don’t need the choice option in the beginning.

      @echo off
      %systemdrive%
      cd %LOCALAPPDATA%\Microsoft\FSX
      rd Shaders /s /q
      rd Shaders10 /s /q
      cd /d “F:\Microsoft Flight Simulator X” —–> “F” is named for MY SSD Drive
      start fsx.exe
      exit

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s