Last active
December 27, 2016 03:50
-
-
Save hamstar/4644534 to your computer and use it in GitHub Desktop.
VBS script to stop Office 2010 corrupting profiles stored on Novell servers due to long file names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' *************************************************** | |
' | |
' What: StopOffice2010Corruptions.vbs | |
' Who: Robert McLeod | |
' When: 27/01/2013 | |
' | |
' This script stops Office 2010 corrupting profiles | |
' by moving the auto recover locations to a folder | |
' that isn't replicated to the file server | |
' | |
' This will probably only work on Windows XP | |
' | |
' *************************************************** | |
const HKEY_CURRENT_USER = &H80000001 | |
strComputer = "." | |
' setup the object we will be using | |
Dim oReg | |
Dim oFSO | |
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") | |
Set oFSO = CreateObject("Scripting.FileSystemObject") | |
Set oShell = WScript.CreateObject("WScript.Shell") | |
' get the user profile | |
userprofile = oShell.ExpandEnvironmentStrings("%USERPROFILE%") | |
' set the reg key paths | |
Dim RegKeyPaths(2) | |
RegKeyPaths(0) = "SOFTWARE\Microsoft\Office\14.0\Word\Options" | |
RegKeyPaths(1) = "SOFTWARE\Microsoft\Office\14.0\PowerPoint\Options" | |
RegKeyPaths(2) = "SOFTWARE\Microsoft\Office\14.0\Excel\Options" | |
' set the value names (nice naming conventions Microsoft! /sarcasm) | |
Dim ValueNames(2) | |
ValueNames(0) = "AUTOSAVE-PATH" ' word | |
ValueNames(1) = "PathToAutoRecoveryInfo" ' powerpoint | |
ValueNames(2) = "AutoRecoverPath" ' excel | |
' set the new locations for the files | |
Dim AutoRecoverLocations(2) | |
AutoRecoverLocations(0) = userprofile & "\Local Settings\Application Data\Microsoft\Word" | |
AutoRecoverLocations(1) = userprofile & "\Local Settings\Application Data\Microsoft\PowerPoint" | |
AutoRecoverLocations(2) = userprofile & "\Local Settings\Application Data\Microsoft\Excel" | |
' Loop through each app and do the things! | |
For i = 0 To 2 | |
' Create the folder incase it doesn't exist | |
If Not oFSO.FolderExists( AutoRecoverLocations(i) ) Then | |
oFSO.CreateFolder AutoRecoverLocations(i) | |
End If | |
' Create the registry values | |
oReg.SetExpandedStringValue HKEY_CURRENT_USER ,RegKeyPaths(i),ValueNames(i),AutoRecoverLocations(i) | |
Next |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment