[Webinar] Streamline your web hosting managementRegister Today


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
  • 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....
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

612 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