Windows 7 Deleting a specific file when W7 is shut down

Discussion in 'Programming and Scripting' started by Carlotto, Oct 13, 2012.

  1. Carlotto

    Carlotto New Member

    Joined:
    Oct 13, 2012
    Messages:
    4
    Likes Received:
    0
    Hello,

    I have some basics of programming but I don’t really know anything about Windows 7 scripting, so here’s my question:

    How can I make it so that a specific file (FNTCACHE.DAT if you’re interested but I doubt it’s important) is deleted everytime I shut down Windows?

    I guess it would have to either be a script which deletes the file when I hit “Shut down” in the start menu or a script which deletes the file then shuts down Windows when run, wouldn’t it?

    Thank you.

    EDIT: I thought I’d give it a try, would this work?
     
    #1 Carlotto, Oct 13, 2012
    Last edited: Oct 13, 2012
  2. patcooke

    patcooke Microsoft MVP
    Staff Member Premium Supporter Microsoft MVP

    Joined:
    May 16, 2010
    Messages:
    5,454
    Likes Received:
    268
    Was just about to suggest similar: (save in a bat file and create link to it on your desktop)

    del %SystemRoot%\System32\fntcache.dat
    %SystemRoot%\System32\shutdown.exe /s /t 0 /f

    also this option for a restart:

    del %SystemRoot%\System32\fntcache.dat
    "%SystemRoot%\System32\shutdown.exe " /r /t 0 /f

    or this one to log off:

    del %SystemRoot%\System32\fntcache.dat
    %SystemRoot%\System32\shutdown.exe /l
     
    #2 patcooke, Oct 13, 2012
    Last edited: Oct 13, 2012
  3. Carlotto

    Carlotto New Member

    Joined:
    Oct 13, 2012
    Messages:
    4
    Likes Received:
    0
    Ok, thanks a lot, I will do that.
     
  4. AceInfinity

    AceInfinity Senior Member
    Microsoft MVP

    Joined:
    Aug 12, 2011
    Messages:
    159
    Likes Received:
    11
    You don't even need to do what patcooke had mentioned, there's a more automatic way of you have the group policy editor. you can set scripts for when you shutdown,startup, etc... Create the script, and call to it on those events..

    In gpedit.msc:
    [​IMG]

    There would be no need for this batch script to replace your regular start button then.

    And I would also specify these flags for the delete operation:
    Code:
    del /f/q %SystemRoot%\System32\fntcache.dat
     

Share This Page

Loading...