Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


VBScript to auto-clear "Enable Offline Files" setting

Posted on 2006-10-24
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?
Question by:jmundsack
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 66

Expert Comment

ID: 17805504
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.
LVL 13

Author Comment

ID: 17805928
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....
LVL 66

Accepted Solution

johnb6767 earned 2000 total points
ID: 17806044
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....
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 13

Author Comment

ID: 17806579
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!
LVL 66

Expert Comment

ID: 17806836
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)
LVL 13

Author Comment

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

LVL 66

Expert Comment

ID: 17808975
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...
LVL 13

Author Comment

ID: 17808988
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.
LVL 66

Expert Comment

ID: 17809261

Expert Comment

ID: 34177391
create script for:  Disables Offline files for desktop computers

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question