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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 484
  • Last Modified:

Scripting a registry key values

Hi,

We've recently discovered that after installing service pack 3 for office 2003 some MS Word documents do not open any more. This is due to the fact that some other software used in our office creates a file with doc extension which updated Office doesn't want to read any more. Now, as I can add exceptions to the registry I'm now trying to write a script to add such exceptions automatically. I have troubles locating OLKXX directory from the script. Someone, please help me do that. Thanks!


Const HKEY_LOCAL_MACHINE = &H80000002
 
strComputer = "."
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Microsoft\Office\11.0\Common\OICEExemptions"
oReg.CreateKey HKEY_CURRENT_USER,strKeyPath
 
strKeyPath = "SOFTWARE\Microsoft\Office\11.0\Common\OICEExemptions"
strValueName = "ExemptionStr_01"
strValue = %userprofile% & "\Impostazioni Locali\Temporary Internet Files\" & OLKXX (THIS LINE IS MY TROUBLE)
 
oReg.SetExpandedStringValue _
    HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

Open in new window

0
Zaurb
Asked:
Zaurb
  • 2
  • 2
1 Solution
 
avatar-eCommented:
OLKXX for Word documents is

"Content.Word"

for other files, for example, misc attached files in Outlook comes and IE temps:

"Content.IE5"
0
 
chandru_solCommented:
Only some files are not opening or any of the word files are not opening
0
 
ZaurbAuthor Commented:
Hi, thanks for responses.

1. Only certain word files do not open. I know these files where created with the other software. That's the reason why after upgrading Office to SP3 such files are blocked. When I write OICEExemptions into registry I can open files.

2. My problem is that I have to write a script which would do this automatically (Insert OCEExemption key and other str values into the registry). T he thing is I don't know how to find out OLKxx from within the script so the script would write the correct path to OLKxx directory into the registry because xx in OLKxx is individual for various installations.

3. Other than that how do I make the script write the correct path into the str value when path should contain %userprofile% ?

Thank you.
0
 
chandru_solCommented:
I think for the first question you have the script

To answer your other questions
2. The below script will find the OLK folder for different users from the registry key
Dim oShell, folderspec, oFS, f, sf, file, f1, count
Set oShell = CreateObject("Wscript.Shell")  
Set oFS = CreateObject("Scripting.FileSystemObject")
folderspec = oShell.RegRead("HKCU\Software\Microsoft\Office\11.0\Outlook\Security\outlooksecuretempfolder")

Set f = oFS.GetFolder(folderspec)
  wscript.echo f.path

3. For the userprofile, use the below script

'script starts here
Dim fso
Dim sFilePath
Dim objShell
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
UserDataPath = ObjShell.ExpandEnvironmentStrings("%userprofile%")

wscript.echo userDatapath


regards
Chandru
0
 
ZaurbAuthor Commented:
Thank you very much!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

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