Solved

Scripting a registry key values

Posted on 2007-11-30
5
470 Views
Last Modified: 2010-04-21
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
Comment
Question by:Zaurb
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:avatar-e
ID: 20386387
OLKXX for Word documents is

"Content.Word"

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

"Content.IE5"
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20386894
Only some files are not opening or any of the word files are not opening
0
 
LVL 1

Author Comment

by:Zaurb
ID: 20390752
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
 
LVL 12

Accepted Solution

by:
chandru_sol earned 125 total points
ID: 20391570
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
 
LVL 1

Author Closing Comment

by:Zaurb
ID: 31411958
Thank you very much!
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

How to record audio from input sources to your PC – connected devices, connected preamp to record vinyl discs, streaming media, that play through your audio card: Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10 – both 32 bit & 64.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

828 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