Page 1 of 1 1
Topic Options
#74231 - 2003-03-28 02:14 AM to move your personal outlook files unattended, check this
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
wrote just a code to my friend who said he is a little busy.

some mumble:
if you need to move say outlook.pst or outlook.prf from local disk to secure backed up homedrive of user this is the code to use.
just place it in logonscript and it should rock just fine.
also remember that it has no error checking. (my scripts newer do)
I was already pointed to write this as UDF but it's not generic enough in my mind to qualify as UDF...
allthough it gives me some thought how to make sreg() simpler and perhaps even faster...

code:
;what files to move:
$fileExtension="pst"
;specify what should be the new location:
$replacePath="u:\Exchange\"
;if file exist in new location should it be overwritten:
$overwrite = "yes"
;remove old or keep:
$remove="yes"

;don't change anything below this
$Profilesroot="HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"
$Profile=-1
do
if len($basekey)
$keyIndex=-1
do
if len($subkey)
$valueIndex=-1
do
if "."+$fileExtension=right($value,4)
if exist($value)
$filename=split($value,"\")
$filename=$filename[ubound($filename)]
if 0=exist($replacePath+$filename) or $overwrite="yes"
copy $value $replacePath+$filename
if $remove="yes"
del $value
endif
$nul=writevalue($Profilesroot+$basekey+"\"+$subkey,$valuename,$replacePath+$filename,"REG_SZ")
endif
endif
endif
$valueIndex=$valueIndex+1
$valuename=enumvalue($Profilesroot+$basekey+"\"+$subkey,$valueIndex)
$value=readvalue($Profilesroot+$basekey+"\"+$subkey,$valuename)
until $value=259 or @error
endif
$keyIndex=$keyIndex+1
$subkey=enumkey($Profilesroot+$basekey,$keyIndex)
until $subkey=259 or @error
endif
$Profile=$Profile+1
$basekey=enumkey($Profilesroot,$Profile)
until $basekey=259 or @error

all crap and comments are welcome [Big Grin]
_________________________
!

download KiXnet

Top
#74232 - 2003-03-28 02:20 AM Re: to move your personal outlook files unattended, check this
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Comment:

We were needing it because we are starting to use DFS and don't want users using UNC to a specific server anymore. We want the .PST file to point to their HOME folder under Exchange.

I would not try to do a COPY of the file during logon. File sizes could be a problem. We do have users with .PST files in excess of 2GB

Nice code though for modifying the Registry to eliminate the UNC path and replace it with a MAPPED drive.

For what it is doing I think it could be generic enough for a UDF.

[ 28. March 2003, 02:21: Message edited by: NTDOC ]

Top
#74233 - 2003-03-28 02:27 AM Re: to move your personal outlook files unattended, check this
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Here is an example of how I envision the UDF could be used.



Break On
UpdatePSTFileToUDrive("pst",u:\Exchange\)

Function UpdatePSTFileToUDrive($fileExtension,$replacePath)
$Profilesroot="HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"
$Profile=-1
do
 if len($basekey)
  $keyIndex=-1
  do
   if len($subkey)
    $valueIndex=-1
    do
     if "."+$fileExtension=right($value,4)
      if exist($value)
       $filename=split($value,"\"
       $filename=$filename[ubound($filename)]
  if exist($replacePath+$filename)
        $nul=writevalue($Profilesroot+$basekey+"\"+$subkey,$valuename,$replacePath+$filename,"REG_SZ")
       endif
      endif
     endif
     $valueIndex=$valueIndex+1
     $valuename=enumvalue($Profilesroot+$basekey+"\"+$subkey,$valueIndex)
     $value=readvalue($Profilesroot+$basekey+"\"+$subkey,$valuename)
    until $value=259 or @error
  endif
   $keyIndex=$keyIndex+1
   $subkey=enumkey($Profilesroot+$basekey,$keyIndex)
  until $subkey=259 or @error
 endif
 $Profile=$Profile+1
 $basekey=enumkey($Profilesroot,$Profile)
until $basekey=259 or @error
EndFunction


Top
#74234 - 2003-03-28 02:30 AM Re: to move your personal outlook files unattended, check this
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Lonkero,

Here are some posts for information on renaming a key in the registry. I'm sure you can whip up something small from the ideas here.

Renaming a registry key
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=1;t=004250

registry Key (trying to rename registry key)
http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=006700#000003

moving renaming and coping registry keys
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=2;t=001005

Top
#74235 - 2003-03-28 02:31 AM Re: to move your personal outlook files unattended, check this
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Do you actually need to specify the .PST extension explicitly?
_________________________
There are two types of vessels, submarines and targets.

Top
#74236 - 2003-03-28 02:36 AM Re: to move your personal outlook files unattended, check this
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Jens,

I think so, so that you don't accidentally replace some other value not related to the .PST data.

I forgot to add the DIMs to my idea of the UDF.

I think Lonk may be working on it as I post. [Big Grin]

Top
#74237 - 2003-03-28 02:44 AM Re: to move your personal outlook files unattended, check this
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no, I still don't like the idea of UDF...
anyway, you can work on it.
I just made the file-copy an option and also colorized my code [Wink]



;what files to move:
$fileExtension="pst"
;specify what should be the new location:
$replacePath="u:\Exchange\"
;if file exist in new location should it be overwritten:
$overwrite = "yes"
;remove old or keep:
$remove="yes"
;copy file or just change regs if file already exists:
$copyFile="yes"

;don't change anything below this
$Profilesroot="HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"
$Profile=-1
do
 if len($basekey)
  $keyIndex=-1
  do
   if len($subkey)
    $valueIndex=-1
    do
     if "."+$fileExtension=right($value,4)
      if exist($value)
       $filename=split($value,"\"
       $filename=$filename[ubound($filename)]
       $exFlag=exist($replacePath+$filename)
       if $exFlag or $copyFile="yes"
        if ($exFlag and $overwrite="yes") or ($copyFile="yes" and $exFlag=0)
          del $replacePath+$filename
          copy $value $replacePath+$filename
        endif
        if $remove="yes"
         del $value
        endif
        $nul=writevalue($Profilesroot+$basekey+"\"+$subkey,$valuename,$replacePath+$filename,"REG_SZ")
       endif
      endif
     endif
     $valueIndex=$valueIndex+1
     $valuename=enumvalue($Profilesroot+$basekey+"\"+$subkey,$valueIndex)
     $value=readvalue($Profilesroot+$basekey+"\"+$subkey,$valuename)
    until $value=259 or @error
   endif
   $keyIndex=$keyIndex+1
   $subkey=enumkey($Profilesroot+$basekey,$keyIndex)
  until $subkey=259 or @error
 endif
 $Profile=$Profile+1
 $basekey=enumkey($Profilesroot,$Profile)
until $basekey=259 or @error

_________________________
!

download KiXnet

Top
#74238 - 2003-03-28 03:09 AM Re: to move your personal outlook files unattended, check this
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
@#%@$%@ Bummer. The code does its job, but looks like the .pst pointer is hidden somewhere else. Changing these values to point to a new location does not affect Outlook 2002

I'll have to do some researching to see where, how this mechanism really works. Maybe it is in an encrpted format somewhere else in the Registry.

Top
#74239 - 2003-03-28 03:12 AM Re: to move your personal outlook files unattended, check this
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Do a registry scan before/after moving the location of a .PST file manually and compare the differences. See Registry Tools
_________________________
There are two types of vessels, submarines and targets.

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 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.058 seconds in which 0.023 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