We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


VBScript to auto-clear "Enable Offline Files" setting

jmundsack asked
Medium Priority
Last Modified: 2011-10-03
Our agency has recently begun using Ghost to re-image PCs when deemed necessary.  The image we use is provided by our parent organization and we cannot change it.  One of the recent tweaks they made to the image was that the Default User profile has the "Enable Offline Files" setting checked (under Folder Options in Windows Explorer).  This was done because the same image we use for our desktops is also used for our laptops--where such a setting actually serves a useful purpose.  For our desktop users, this setting is not only unncessary, but terribly confusing--whenever the user logs off, they get confusing messages about "synchronizing files," or worse, error messages telling them that "such-and-such file cannot be synchronized."

What I want to do is add a statement to the logon script for our desktop PC users, that clears this setting.

Can this be done?
Watch Question

Most Valuable Expert 2011
Top Expert 2011

We have our GPO's divided by Laptops and Workstations, and the Workstations OU doesnt get the Offline folders. Just a thought...

Here is a page at MS talks about the NetCache..Might have een it already..Tells how to disable it in the registry and via GPO


Unfortunately, I am not a scripter, outside of DOS, so I cannot help with that portion.


Well, the scripting is the easy part, for me.

I really had my hopes up with the page you referenced.  Unfortunately, in practice, what I found was this:

I went to one of the desktops where the "Enable Offline Files" is checked.  I ran my script which creates the "Enabled" DWORD, set to zero (which, according to the webpage, means, "Offline Files is disabled, and users cannot enable it").  Then I went back to the Folder Options dialog, and, the "Enable Offline Files" box WAS indeed disabled; however, it was STILL CHECKED!  LOL

The description, "Offline Files is disabled..." suggests it would uncheck the box, and "users cannot enable it" suggests they couldn't check it even if they tried.  But perhaps the part about "Offline Files is disabled" only applies to NEW profiles on the machine--that is, it won't alter the setting for users who already have it enabled?

I will check this out....
Most Valuable Expert 2011
Top Expert 2011
Try this on the system you tested at....

Does the system still try and synchronize?

If so, se this method to reinitialize the CSC cache...Once it is empty, and no further offline files being enabled, it might work...

How to re-initialize the offline files cache and database

Our laptops that have the Offline files GPO applied, still haev teh box checked, but since they cant right click or context menu select to make available, no synchronizations happen....

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Well how's this for a nice turn of events?

When I did BOTH things:

1. Create HKLM\SOFTWARE\Policies\Microsoft\Windows\NetCache\Enabled (DWORD = 0)
2. Create HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache\FormatDatabase (DWORD = 1)

And then restarted the computer, the result is EXACTLY what I was looking for: the box is unchecked, and it's disabled so it cannot BE checked!  Perfect!  Now all I have to do is figure out how to automatically restart Windows XP from VBScript, but that's beyond the scope of this question.

In case you're interested, here is the VBScript code to do the above:

    Dim oWshShell
    Set oWshShell = CreateObject("Wscript.Shell")
    oWshShell.RegWrite  "HKLM\SOFTWARE\Policies\Microsoft\Windows\NetCache\Enabled", 0, "REG_DWORD"
    oWshShell.RegWrite  "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache\FormatDatabase", 1, "REG_DWORD"

Thank you for all your expert help!
Most Valuable Expert 2011
Top Expert 2011

No problem. Keep in mind there is a shutdown command built in from command line.....

again, not knowing scripting....

shutdown -r -t 60

H:\>shutdown /?
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]

        No args                 Display this message (same as -?)
        -i                      Display GUI interface, must be the first option
        -l                      Log off (cannot be used with -m option)
        -s                      Shutdown the computer
        -r                      Shutdown and restart the computer
        -a                      Abort a system shutdown
        -m \\computername       Remote computer to shutdown/restart/abort
        -t xx                   Set timeout for shutdown to xx seconds
        -c "comment"            Shutdown comment (maximum of 127 characters)
        -f                      Forces running applications to close without warning
        -d [u][p]:xx:yy         The reason code for the shutdown
                                u is the user code
                                p is a planned shutdown code
                                xx is the major reason code (positive integer less than 256)
                                yy is the minor reason code (positive integer less than 65536)


Yep--I did find that command as soon as I started searching.  Thank you for the extra-credit effort though!

Most Valuable Expert 2011
Top Expert 2011

No problem, and since I dont know when to quit, Make sure you dont have that FormatDatabase value running every launch, as it may slow the PC down next boot. I would say after a week or so, remove the values form teh script altogether, since they more than likely would all be hit by then...


Hey, I appreciate it.  But actually this isn't going to be in a login script.  It will be something we run after reimaging a machine--one shot deal per machine.  Actually we already have a script that we run to install some additional software on top of the image (I work for a county government agency--we get our image from the state, without our local apps on it, and then we install the local apps).  So, I've just tacked this script onto the end of that software install script, and we're gold.  Thanks again for your help and for covering all the bases.
Most Valuable Expert 2011
Top Expert 2011

create script for:  Disables Offline files for desktop computers
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.