#75134 - 2003-05-22 01:02 PM
Copy copies to wrong folder
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
|
Hi,
We are implementing a default stationery following company colors, font types and all that stuff in Outlook. Stationery and all the settings are working fine.
I need to copy the default stationery from the logon server to the client at every logon. Copying the file seems to go OK but the script copies the file to the folder it is running from and not to the folder I specify. I replaced the destination path with c:\test and it works fine. Only one little problem, outlook can't open stationery from any other folder then its default folders.
Been trying for two days, ready to destroy my computer now.
Does anybody have an idea?
The code that's troubling me starts at the start her line and stops at the stop here line. All other lines work fine.
code:
;=============================================================================================== ;**** Created with KiXscripts Editor | http://KiXscripts.com **** ;**** Last Modified on 22-05-2003 at 11:50:19 **** ;=============================================================================================== ; ;Sets default stationery for outlook XP (10.0) ; ;Check if outlook is installed $Outlookexist = Exist ("c:\program files\microsoft office\office10\outlook.exe") If ($Outlookexist = 1) Goto copy_stationery Goto End ; :copy_stationery $userprofile = %userprofile% $USerprofile1 = $Userprofile + "\Application Data\Microsoft\Stationery\" ; ; start here If Exist ("$Userprofile1" + "CorpStationery.htm") = 0 Shell "%COMSPEC% /E:1024 /C COPY " + @LDRIVE + "\Stationery\CorpStationery.htm" $Userprofile1 Else $LOCAL = GetFileTime ("$Userprofile1" + "CorpStationery.htm") $LOGON = GetFileTime (@LDRIVE + "\Stationery\" + "CorpStationery.htm") If ($LOCAL <> $LOGON) Shell "%COMSPEC% /E:1024 /C COPY " + @LDRIVE + "\Stationery\CorpStationery.htm" $Userprofile1 EndIf
EndIf ; stop here ; ;Set stationery ; ;Find User ID $User = EnumKey("HKEY_USERS", 1) ; ;set mail format to HTML (65536 for plain text, 196610 for rich text, 131072 for HTML) $rc = WriteValue("HKEY_USERS\$User\Software\Microsoft\Office\10.0\Outlook\Options\Mail", "EditorPreference", "131072", "REG_DWORD") ; ;Set Company stationery ; ;Add the key $rc = AddKey("HKEY_USERS\$User\Software\Microsoft\Office\10.0\Common\MailSettings\NewStationery") ; Write value to the key $rc = WriteValue("HKEY_USERS\$User\software\Microsoft\Office\10.0\Common\MailSettings", "NewStationery", "CorpStationery", "REG_EXPAND_SZ") ; :End
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
|
Top
|
|
|
|
#75138 - 2003-05-22 02:46 PM
Re: Copy copies to wrong folder
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
R2D2,
Expanding your code. Note: the implementation of COMPAREFILETIMES..
code:
;Check if outlook is installed $outlook=READVALUE("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE","") $outlookexist = Exist($outlook) IF ($outlookexist) GOTO copy_stationery ELSE GOTO End ; :copy_stationery $appdata=READVALUE("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\","AppData") $userprofile1 = $appdata+"\Microsoft\Stationery\" $local = "$Userprofile1" + "CorpStationery.htm" $logon = @ldrive + "\Stationery\" + "CorpStationery.htm" ; ; start here IF Exist ($local) = 0 SHELL "%COMSPEC% /E:1024 /C COPY " + $logon $userprofile1 ELSE IF COMPAREFILETIMES($local, $logon) SHELL "%COMSPEC% /E:1024 /C COPY " + $logon $userprofile1 ENDIF
ENDIF ;Note: Never did find the missing endif here ENDIF
Now, if we take Jochen's suggestion..
code:
;Check if outlook is installed $outlook=READVALUE("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE","") $outlookexist = Exist($outlook) IF ($outlookexist) GOTO copy_stationery ELSE GOTO End ; :copy_stationery $appdata=READVALUE("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\","AppData") $userprofile1 = $appdata+"\Microsoft\Stationery\" $local = $userprofile1 + "CorpStationery.htm" $logon = @ldrive + "\Stationery\CorpStationery.htm" ; ; start here IF Exist ($local) = 0 COPY $logon "$Userprofile1" ELSE IF COMPAREFILETIMES($local, $logon) COPY $logon "$Userprofile1" ENDIF
ENDIF ;Note: Never did find the missing endif here ENDIF
Does this work?
Kent [ 22. May 2003, 14:48: Message edited by: kdyer ]
|
|
Top
|
|
|
|
#75140 - 2003-05-23 08:18 AM
Re: Copy copies to wrong folder
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
R2,
Can you let us know if this works for you?
Thanks.
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 837 anonymous users online.
|
|
|