Solved

Scripting a registry key values

Posted on 2007-11-30
5
465 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

Too many email signature updates to deal with?

Do you feel like you are taking up all of your time constantly visiting users’ desks to make changes to email signatures? Wish you could manage all signatures from one central location, easily design them and deploy them quickly to users? Well, there is an easy way!

Join & Write a Comment

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now