Go Premium for a chance to win a PS4. Enter to Win

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2631
  • Last Modified:

VBScript to auto-clear "Enable Offline Files" setting

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?
  • 5
  • 4
1 Solution
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.
jmundsackAuthor Commented:
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....
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....

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

jmundsackAuthor Commented:
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!
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)
jmundsackAuthor Commented:
Yep--I did find that command as soon as I started searching.  Thank you for the extra-credit effort though!

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...
jmundsackAuthor Commented:
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.
create script for:  Disables Offline files for desktop computers

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now