Jump to content

Offline Files


MadBoy
 Share

Recommended Posts

Description:

This script will let you change most of the Offline Files Settings that can be found at Folder Options - Offline Files tab.

Notes:

Must be run with admin rights account.

Whole string is one big parameter. There can be no spaces inside the parameter string. It can only contain commas which divide settings.

Requires LogOff or Reboot to apply changes (unless someone can provide better solution?)

Return Codes:

1 - Failure writing to registry (overall failure)

2 - Wrong amount of parameters

4 - Wrong parameters values

Usage:

==> script.exe EnableOfflineFiles=yes,DefCacheSize=1,NoReminders=yes,ReminderFreqMinutes=60,SyncAtLogoff=yes,SyncAt

Logon=no

Descriptions of params as per Folder Options - Offline Files tab

a) EnableOfflineFiles -> Enable Offline Files (possible options are yes or no)

:) DefCacheSize -> Amount of disk space to use for temporary offline files (Values are in percents. Values taken between 0 and 100)

c) NoReminders -> Display a reminder every (possible options are yes or no). No means that the checkbox will be checked and yes means that the checkbox will be unchecked.

d) ReminderFreqMinutes -> Display a reminder every XXX minutes (Values are in minutes. Values taken between 1 and 9999)

e) SyncAtLogoff -> Synchronize all offline files when logging off (possible options are yes or no)

f) SyncAtLogon -> Synchronize all offline files before logging on (possible options are yes or no)

If $CmdLine[0] = 1 Then
    Global $params_only = StringSplit($CmdLine[1], ",", 1)
    If IsArray($params_only) Then
        For $a = 1 To $params_only[0]
            Select
                Case StringInStr($params_only[$a], "EnableOfflineFiles", 1)
                    $value_enable_offline_files = StringTrimLeft($params_only[$a], StringLen("EnableOfflineFiles="))
                    If $value_enable_offline_files = "yes" Then
                        $return = RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache", "Enabled", "REG_DWORD", "1")
                        If $return = 0 Then    Exit (1)
                    Else
                        $return = RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache", "Enabled", "REG_DWORD", "0")
                        If $return = 0 Then    Exit (1)
                    EndIf        
                Case StringInStr($params_only[$a], "DefCacheSize", 1)
                        $value_def_cache_size = StringTrimLeft($params_only[$a], StringLen("DefCacheSize="))
                    If StringIsInt($value_def_cache_size) Then
                        $value_def_cache_size = Number($value_def_cache_size)
                        If $value_def_cache_size >= 0 And $value_def_cache_size <= 100 Then
                            $return = RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache", "DefCacheSize", "REG_DWORD", $value_def_cache_size*10)
                            If $return = 0 Then    Exit (1)
                        Else
                            Exit(4) ; Wrong parameters values
                        EndIf
                    Else
                        Exit(4) ; Wrong parameters values
                    EndIf
                Case StringInStr($params_only[$a], "NoReminders", 1)
                    $value_no_reminders = StringTrimLeft($params_only[$a], StringLen("NoReminders="))
                    If $value_no_reminders = "yes" Then
                        $return = RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache", "NoReminders", "REG_DWORD", "1")
                        If $return = 0 Then    Exit (1)
                    Else
                        $return = RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache", "NoReminders", "REG_DWORD", "0")
                        If $return = 0 Then    Exit (1)
                    EndIf                        
                Case StringInStr($params_only[$a], "ReminderFreqMinutes", 1)
                    $value_reminder_freq_minutes = StringTrimLeft($params_only[$a], StringLen("ReminderFreqMinutes="))
                    If StringIsInt($value_reminder_freq_minutes) Then
                        $value_reminder_freq_minutes = Number($value_reminder_freq_minutes)
                        If $value_reminder_freq_minutes >=1 And $value_reminder_freq_minutes <= 9999 Then
                            $return = RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache", "ReminderFreqMinutes", "REG_DWORD", $value_reminder_freq_minutes)
                            If $return = 0 Then    Exit (1)
                        Else
                            Exit (4)
                        EndIf
                    Else
                        Exit(4)
                    EndIf
                Case StringInStr($params_only[$a], "SyncAtLogoff", 1)
                    $value_sync_at_logoff = StringTrimLeft($params_only[$a], StringLen("SyncAtLogoff="))
                    If $value_sync_at_logoff = "yes" Then
                        $return = RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache", "SyncAtLogoff", "REG_DWORD", "1")
                        If $return = 0 Then    Exit (1)
                    Else
                        $return = RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache", "SyncAtLogoff", "REG_DWORD", "0")
                        If $return = 0 Then    Exit (1)
                    EndIf                    
                Case StringInStr($params_only[$a], "SyncAtLogon", 1)
                    $value_sync_at_logon = StringTrimLeft($params_only[$a], StringLen("SyncAtLogon="))
                        If $value_sync_at_logon = "yes" Then
                        $return = RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache", "SyncAtLogon", "REG_DWORD", "1")
                        If $return = 0 Then    Exit (1)
                    Else
                        $return = RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache", "SyncAtLogon", "REG_DWORD", "0")
                        If $return = 0 Then    Exit (1)
                    EndIf    
                Case Else
                    Exit(2)                    
            EndSelect
        Next
    Else
        Exit (2)
    EndIf
Else
    Exit (2)
EndIf

My little company: Evotec (PL version: Evotec)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...