Page 1 of 1 1
Topic Options
#75134 - 2003-05-22 01:02 PM Copy copies to wrong folder
Mart Moderator Offline
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
#75135 - 2003-05-22 01:20 PM Re: Copy copies to wrong folder
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Apart from the answer to your problem:
Why not simply use Kixtart's intrinsic copy command ?
Depending on the version you use it is adequate enough plus it provides simplier code and reliability regarding errorlevels ...
_________________________



Top
#75136 - 2003-05-22 01:27 PM Re: Copy copies to wrong folder
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Now to the answer :

try it with :


Shell '%COMSPEC% /E:1024 /C COPY "' + @LDRIVE + '\Stationery\CorpStationery.htm" "' + $Userprofile1 + '" >nul 2>nul'


hth
_________________________



Top
#75137 - 2003-05-22 02:18 PM Re: Copy copies to wrong folder
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Thanx Jochen.
This works fine.
_________________________
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 Offline
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 ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#75139 - 2003-05-22 02:48 PM Re: Copy copies to wrong folder
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Then you might also want to check for correct filesize in addition to correct filetime.
_________________________
There are two types of vessels, submarines and targets.

Top
#75140 - 2003-05-23 08:18 AM Re: Copy copies to wrong folder
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
R2,

Can you let us know if this works for you?

Thanks.
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#75141 - 2003-05-31 12:18 AM Re: Copy copies to wrong folder
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Sorry for the delay but we did some refurbishing in our office so this project has been in the fridge until we moved to our "new" office.

Jochen's suggestion worked fine.
Will be testing Kdyer's suggestion next week. Will let you know if it works for me.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.061 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org