1.

Solve : Help with script (please!)?

Answer»

Okay so my goal here is to have a script search a users' homedrive for any and all pst files. It will then edit a text file and update certain LINES of the text file with the path to the pst, the END goal being for the script (or a series of scripts) to compile a .prf file used to import config info into Outlook. Here's the code I'm using right now:

Code: [Select]@echo off
for /f "delims=" %%q in ('dir /b /s %homedrive%\*.pst') do call :prf "%%q"
:prf
for /f "delims=" %%a in (%temp%\prf.txt) do call :process "%%a" "%~1"

goto EOF
:process
set line=%~1
if /i "%line%"=="PathToPersonalFolders=" set line=PathToPersonalFolders=%~2
echo %line% >> "%temp%\test.txt"
:EOF

The contents of prf.txt is:
Code: [Select][SERVICE2]
UniqueService=No
Name=Personal Folder
PathToPersonalFolders=
EncryptionType=0x40000000

Right now it works fine EXCEPT it adds the contents of prf.txt one too many times, so I end up with this:

[Service2]
UniqueService=No
Name=Personal Folder
PathToPersonalFolders=H:\Mail\personal folder.pst
EncryptionType=0x40000000
[Service2]
UniqueService=No
Name=Personal Folder
PathToPersonalFolders=H:\Mail\Personal Folder - MGMT.pst
EncryptionType=0x40000000
[Service2]
UniqueService=No
Name=Personal Folder
PathToPersonalFolders=H:\Mail\Personal Folders - IT.pst
EncryptionType=0x40000000
[Service2]
UniqueService=No
Name=Personal Folder
PathToPersonalFolders=
EncryptionType=0x40000000

I can't figure out why it's doing this, help!It appears the :process logic is executed twice, one from the first for statement by way of the :prf logic and then by falling into the :prf logic on it's way to the goto statement.

I think you may just have to re-sequence your logic (put the goto statement immediately after the first for statement.Sidewinder, as always, you are the man. The script works pretty much as expected now. After I moved the "goto EOF", it started adding "ECHO is off." at the end of each echo, but whatever, that's fine, Outlook will ignore the line when importing the prf. Once I have everything figured out I'll post the FINAL script for everyone, hopefully somebody else can get some use out of it too. adding a second "goto EOF" after the second "for" fixed the echo thing btw.It's all done! Thanks to sidewinder for his help is solving some of the issues. There doesn't seem to be an attachment option on this forum so if anybody would like the script just drop me a pm and i'll e-mail it. To recap what it does is creates and imports an outlook prf. The prf includes a pab and and all existing pst's on the users %homedrive%. Also changes some misc settings in outlook.



Discussion

No Comment Found