#207326 - 2013-05-17 08:31 PM
Bit of an odd issue
|
Tsguy
Getting the hang of it
Registered: 2010-01-18
Posts: 67
Loc: Oregon
|
Hello kixers,
Kind of a long story on this issue but I'll try and keep it short. We have a hosted application on our terminal servers that requires an Outlook profile for users in order to allow them to e-mail. We have for a long time maintained a scripted process that would launch outlook in the background for new users in order to setup their outlook profile for their session, and we'd then save that profile info to the network for use with other apps.
Every so often, this process breaks down, and a users outlook profile on the TS servers gets messed up. To correct this, the administrators need to delete a few files, and ask the user to re-run their app.
I am looking to automate this Outlook profile default process for our administrators and our users.
My first effort at this was 3 scripts.
1) CMD script that called to a kix script 2) kix script provided a messagebox, and with the proper selections would RUN the third CMD scirpt 3) CMD script would do all the dirty work, delete and recreate values to reset the outlook profile.
This whole setup worked very well. What I was unable to get to work to my liking was messaging. I wanted message boxes to occur a specific intervals in the script, and couldn't get the timing right (either they'd not show up at all, or they'd all show up at once).
The more I tinkered, the more complex the script became, and the less it functioned. So I decided to backup and recreate the whole project in Kix.
I have been able to get everything to work as I want in Kix, except for one rather bizarre issue. Within the script, after the recreation of Outlook directory and registry values, I place a call to launch outlook. When this occurs in my CMD script version of this project, outlook launches directly into the Inbox . .no profile setup prompts with "next" etc. The very same commands from my kix script . . get the Outlook profile setup window prompts.
I have debug'd my code, and haven't been able to sort out where the break down is. Posting my original "CMD" scipt, and my KIX script. Suggestions greatly appreciated:
CMD script to reset outlook profile to defaults:
@echo off
REM * This script's purpose is to delete and recreate all components of a user's mail profile *
REM
REM * This script is only intended to be run for repairing outlook on the terminal servers *
REM
REM We start with closing outlook processes if they are still running.
taskkill /IM ObClnt32.exe /F
taskkill /IM Outlook.exe /F
taskkill /IM CTFMON.exe /F
taskkill /IM obunity.exe /F
REM Lets pause for a few moments to make sure everything is closed
Timeout /T 5 /NOBREAK
REM Now we're going to delete the current Office settings for our user.
REM First we'll delete the data saved to the network.
Del "\\netshare\userconfigs$\%username%\PSCitrixconfig\Outlook\Outlookran.txt" /q
Del "\\netshare\userconfigs$\%username%\PSCitrixconfig\Outlook\Outlookmessaging.reg" /q
Del "\\netshare\userconfigs$\%username%\PSCitrixconfig\Outlook\Office.reg" /q
REM second we delete the local data
Reg Delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem" /va /f
Reg Delete "HKCU\Software\Microsoft\Office\14.0\Outlook\Setup" /v FirstRun /f
Reg Delete "HKCU\Software\Microsoft\Office\14.0\Outlook\Setup" /v First-Run /f
Reg Delete "HKCU\Software\Microsoft\Office\14.0\Outlook\Setup" /v ImportPRF /f
RD "c:\users\%username%\Appdata\Local\Microsoft\Outlook" /S /Q
RD "C:\users\%username%\Appdata\Roaming\Microsoft\Outlook" /S /Q
REM now that all data has been purged, lets pause again to catch our breath.
Timeout /T 5 /NOBREAK
REM Now we recreate profile folders and insert the default Outlook startup registry values
MD "c:\users\%username%\Appdata\local\Microsoft\Outlook"
MD "c:\users\%username%\Appdata\Roaming\Microsoft\Outlook"
Reg Add "HKCU\Software\Microsoft\Office\14.0\Outlook\Setup" /v FirstRun /t Reg_dword /d 0
Reg Add "HKCU\Software\Microsoft\Office\14.0\Outlook\Setup" /v First-Run /t Reg_dword /d 0
Reg Add "HKCU\Software\Microsoft\Office\14.0\Outlook\Setup" /v ImportPRF /t Reg_Sz /d "c:\Progra~2\Micros~2\Custom14.prf"
REM In theory our settings have been defaulted, now lets try launching Outlook.
Timeout /T 5 /NOBREAK
Start Ctxhide.exe "C:\Program Files (x86)\Microsoft office\office14\Outlook.exe"
Xcopy "C:\scripts\Outlookran.txt" "\\netshare\userconfigs$\%username%\PsCitrixConfig\Outlook" /Y
Timeout /T 5 /NOBREAK
taskkill /IM Outlook.exe /F
taskkill /IM CTFMON.exe /F
regedit /E "\\netshare\userconfigs$\%username%\PsCitrixConfig\Outlook\Outlookmessaging.reg" "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem"
regedit /E "\\netshare\userconfigs$\%username%\PsCitrixConfig\Outlook\Office.reg" "HKEY_CURRENT_USER\Software\Microsoft\Office"
Timeout /t 5 /NOBREAK
c:
cd\
exit
And the KIX version of this project (this script calls out to a few CMD files that perform tasks I couldn't get kix to do in debug will try and flesh each of those out as best I can):
SetConsole('SHOW')
;
; Declaring Global Variables
;
DIM $Selection ;Used to determine the button pressed by the user.
DIM $FILE1 ; OutlookRan.txt on netshare share
DIM $FILE2 ; OutlookMessaging.reg on netshare share
DIM $FILE3 ; Office.reg on netshare share
DIM $FILE4 ; Default PRF file for profile setup
DIM $FILE5 ; OutlookRan.txt check file
DIM $PATH1 ; Path to Outlook folder on netshare
DIM $PATH2 ; Local Appdata path to Outlook settings
DIM $PATH3 ; Roaming Appdata path to Outlook settings
DIM $REGPATH1 ; Registry key path to Windows Messaging subsystem
DIM $REGPATH2 ; Registry key path to FirstRun Setup key
DIM $REGPATH3 ; Registry key path to First-Run Setup key
DIM $REGPATH4 ; Registry key path to ImportPRF Setup key
DIM $APP ; The EXE we want to run
DIM $KILLAPP1 ; script that makes sure Outlook is not running
DIM $REGEXPORTS ; script for registry exports
;
$Rc = SetOption('NoVarsInString', 'On')
$Rc = SetOption('NoMacrosInString', 'On')
;
; Specify File and Path Variables
;
$FILE1 = '\\netshare\userconfigs$\' + @userid + '\PsCitrixConfig\Outlook\Outlookran.txt'
$FILE2 = '\\netshare\userconfigs$\' + @userid + '\PSCitrixConfig\Outlook\OutlookMessaging.reg'
$FILE3 = '\\netshare\userconfigs$\' + @userid + '\PSCitrixConfig\Outlook\Office.reg'
$FILE4 = 'c:\Progra~2\Micros~2\Custom14.prf'
$FILE5 = 'c:\Scripts\OutlookRan.txt'
$PATH1 = '\\netshare\userconfigs$\' + @userid + '\PSCitrixConfig\Outlook'
$PATH2 = 'c:\users\' + @userid + '\Appdata\Local\Microsoft\Outlook'
$PATH3 = 'c:\users\' + @userid + '\Appdata\Roaming\Microsoft\Outlook'
;
; Specify Registry Path Variables
;
$REGPATH1 = 'HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem'
$REGPATH2 = 'HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Setup'
$REGPATH3 = 'HKEY_CURRENT_USER\Software\Microsoft\Office'
;
; Specify application variables
;
$APP = 'C:\scripts\Apphelpscripts\LaunchOutlook.cmd'
;
; Specify additional script variables
;
$KILLAPP1 = 'c:\scripts\apphelpscripts\taskkilloutlook.cmd'
$REGEXPORTS = 'c:\scripts\apphelpscripts\regexports.cmd'
;
; Provide the user a popup message asking them if they want to proceed with this script or to exit.
;
$Selection = MessageBox ("This will rebuild your Outlook profile, Do you wish to continue? Press YES to rebuild your outlook profile, or press NO to cancel", " Rebuild Outlook profile", 36)
If $Selection = 6
; Now we're going to start deleteing data
MessageBox ("Once you click OK on this message the Outlook reset process will start. Please wait until you see another message informing you the rebuild has completed before using any office applications.", " Outlook profile rebuild started.....", 0, 10)
RUN $KILLAPP1
Sleep 5
DELTREE ($REGPATH1)
DELVALUE ($REGPATH2, "FirstRun")
DELVALUE ($REGPATH2, "First-Run")
DELVALUE ($REGPATH2, "ImportPRF")
DEL $FILE1 /c
DEL $FILE2 /c
DEL $FILE3 /c
SHELL '%comspec% /c RD $PATH2 /S /Q'
SHELL '%comspec% /c RD $PATH3 /S /Q'
Sleep 5 ; script paused for 5 seconds, after the pause we start re-adding default data
MD $PATH2
MD $PATH3
WriteValue ($REGPATH2, "FirstRun", "0", "REG_DWORD")
WriteValue ($REGPATH2, "First-Run", "0", "REG_DWORD")
WriteValue ($REGPATH2, "ImportPRF", $FILE4, "REG_SZ")
SLEEP 5 ; Now we're going to start outlook up
RUN $APP
SLEEP 10 ; Pausing the let outlook sort out it's profile, next we kill Outlook.
RUN $KILLAPP1
SLEEP 5 ; Pause a moment to let Outlook close and clean up, then we copy our correct outlook profile settings out to our network share for safe keeping
COPY $FILE5 $PATH1
RUN $REGEXPORTS
SLEEP 5 ; Last pause before our final message box.
MessageBox ("Your Outlook profile has been Rebuilt, and your e-mail should now work properly. If you continue to have problems with using Outlook, please open a Helpdesk or contact extention 2500.", " Outlook Profile Rebuild Completed!", 0, 10)
ELSE
EXIT
ENDIF
EXIT
There are 3 calls currently within the kix script to other scripts to perform functions I was unable to get working with Kix coding directly.
1) Taskkill, for some reason this wasn't working for me properly from kix, so I put it in CMD and it works fine. This is the command I was originally trying to run, before I placed a call to a CMD file as a replacement.
shell '%comspec% /c Taskkill /IM outlook.exe /F'
2) Starting Outlook. Originally I just did the code below, when that didn't work I tried calling out to a CMD file that runs the same command as my original script:
$APP = 'c:\program files (x86)\Microsoft\Office\Outlook.exe'
RUN $App
3) Registry exports. This function I also started with a shell reference but the exports never occured, so again, I dropped to running a CMD file that exports no problem. Kix code attempted:
shell '%compspec% /c Reg Export $REGPATH3 $FILE3'
Well I kinda tried to keep it short ;). The meat of this process is the deletion of 3 reg values and 1 reg key under HKCU, along with the deletion of 2 folders under the user profile. By having the "firstrun" keys setup in the right spot in the registry for outlook, along w/ a PRF file pointer, outlook will 'auto' build it's profile when users start it.
Aside from the language differences, I can't sort out why I'm having different results with launching outlook after the scripts are run. Thoughts?
Much thanks for reading thru all this 
-Lan
PS - my kix build version = 4.62.0.0
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 952 anonymous users online.
|
|
|