Recently I have been involved in a project to roll out Microsoft RemoteApps, so users can launch applications on a terminal server via a website or shortcut. One of the issues we had was with a business application that was trying to send email out via Outlook.
The application was trying to open a new outlook email, but as outlook had never been launched before the application just hit an error as soon as it tried to send the email. I came across a few articles that pointed at adding a entry to the registry at HKCU\Software\Microsoft\Office\14.0\Outlook\Setup\ImportPRF that contains a path to a prf file. When you set this path when Outlook first opens it will use this entry to create the profile based on the settings in the PRF file.
The problem I had was because Outlook was not actually being opened by the user, then the profile was never created, so they got an error. So in order to get around this, I decided to write a VB script that would create a Outlook object then launch the application. I would then use this as the application path in RemoteApp Manager to start the application.
This is the script I wrote to launch my application:
SetobjRegistry = CreateObject("Wscript.shell")
objRegistry.RegWrite "HKCU\Software\Microsoft\Office\14.0\Outlook\Setup\ImportPRF", "\\server\share\settings.prf", "REG_SZ"
SetobjOutlook = CreateObject("Outlook.Application")
SetobjNamespace = objOutlook.GetNamespace("MAPI")
SetobjFolder = objNamespace.GetDefaultFolder(6)
objRegistry.Run "%SYSTEMDRIVE%\Progam Files\App1\App1.exe"
So, what is the script doing. First of all we create a shell object so we can write to the registry. Then we write the key to point at our prf file (obviously you need to change this to your relevant path, and if you are not running Outlook 2010 the reg path will be different).
Now we have that setting in the reg, we create an object pointing at Outlook. As we do this Outlook essentially ‘runs’ and sets its self up based on the info in the prf. We then just shell out to the application we want to run, and an Outlook profile should be available for the application to use!