Page 1 of 1 1
Topic Options
#152669 - 2005-12-01 06:43 PM Working within Documents and Settings
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
I want to be able to rename a file within Documents and Settings on multiple XP boxes. The problem is the file exists below the username so the path changes with each PC. Can anyone point me in the right direction? Here's what I've tried but it doesn't seem to work:

if exist ("C:\Documents and Settings\"+username+"\Application Data\Microsoft\Outlook\Outlook.nk2")
ren "C:\Documents and Settings\"+username+"\Application Data\Microsoft\Outlook\Outlook.nk2" nk2.old


Thanks

Top
#152670 - 2005-12-01 07:05 PM Re: Working within Documents and Settings
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Hello jszei and welcome to the board.

Well an issue with your approach is that the name often will not be OUTLOOK.NK2 but may be the name of the user's logon ID or there may be multiple names in the same folder due to multiple profiles by the same user maybe even on a shared machine.

Please give this a try and see how it works.
 
Code:
Dim $NK2
$NK2=ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'AppData')
If Exist($NK2+'\Microsoft\Outlook\*.nk2')
SHELL '%COMSPEC% /c REN ' + '"'+$NK2+ '\Microsoft\Outlook\*.nk2'+'"'+' *.old'
EndIf


 

Top
#152671 - 2005-12-02 09:30 AM Re: Working within Documents and Settings
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
So did this work out for you jszei
Top
#152672 - 2005-12-05 11:42 PM Re: Working within Documents and Settings
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
Thank you for the warm welcome. I hope to visit this site more often.
Yes, NTDOC, it worked perfectly. I appreciate the advice on having the script check the wildcard as the nk2 file does depend on the profile name. I also added a preliminary check so I didn't turn this into a loop:

Dim $NK2
$NK2=ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'AppData')
If Exist($NK2+'\Microsoft\Outlook\*.old')
QUIT
EndIf


Many thanks,

John

Top
#152673 - 2005-12-06 01:13 AM Re: Working within Documents and Settings
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
QUIT 0
EndIf
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#152674 - 2005-12-06 03:15 AM Re: Working within Documents and Settings
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Well sort of depends on how you want this to operate and why you're renaming them anyways. There are keys to disable this feature too if wanted.

Basically if it is a temporary thing then you might want to set a flag so that you don't run it again.

Top
#152675 - 2005-12-06 07:24 PM Re: Working within Documents and Settings
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
It is temporary. We wanted to flush everyone's cache as we migrate Exchange servers. Once is enough that's why I included that statement.
What does the 0 in Quit 0 do?

Another question for your guys if you don't mind. I'm trying to make this registry change for everyone as in the past we disabled the autoname check / caching features but want to reinable it. Here's the entry.

[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Preferences]
"ShowAutoSug"=-

What's the best way to do this? You mentioned a way to flag it so it only runs once...

Thanks,

John

Top
#152676 - 2005-12-06 09:29 PM Re: Working within Documents and Settings
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
See the FAQ:
EXIT [error level / exit code] optional or not?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#152677 - 2005-12-08 04:55 AM Re: Working within Documents and Settings
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Force the setting via GPO or via WRITEVALUE()
_________________________
There are two types of vessels, submarines and targets.

Top
#152678 - 2005-12-08 09:54 AM Re: Working within Documents and Settings
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
A flag is normally like a zero byte size file or an entry in the registry that you look for to determine if your script has run or not as it only creates that file after a run of your script.

Why not just disable it all together until after the migration, then turn it back on.

Top
#152679 - 2005-12-08 05:32 PM Re: Working within Documents and Settings
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
We still have NT DC's for network authentication and will not be migrating to AD until next year so GPO's are out. Our email servers are however on their own AD domain. The migration off of 5.5 is nearly complete. At least as far as what I am responsible for is concerned. We originally disabled the cache so no refrences would be made to the old 5.5 servers. Now we are renaming the cache so a new nick or nk2 file is created when Outlook is run. The key here is to eliminate any reference to the old 5.5 servers.
Can anyone point me in the right direction to implement the following key deletion with kix. I know it's simple but I am new to kix & want to get the format correct. Do I just put WRITEVALUE before the key and put the whole thing in parenths? Thanks.

[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Preferences]
"ShowAutoSug"=-

Top
#152680 - 2005-12-08 07:27 PM Re: Working within Documents and Settings
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Well you don't need to remove the value to disable it you just need to set it to 0


Code:
Dim $NoSuggest
$NoSuggest=WriteValue('HKCU\Software\Microsoft\Office\11.0\Outlook\Preferences','ShowAutoSug',0,REG_DWORD)



If you want to remove the value then this will work

Code:
Dim $RemoveSuggest
$RemoveSuggest=DelValue('HKCU\Software\Microsoft\Office\11.0\Outlook\Preferences','ShowAutoSug')


 

Top
#152681 - 2005-12-13 11:23 PM Re: Working within Documents and Settings
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
NTDOC,

The value doesn't exist in a fresh install of Outlook. We added it and setting the value to 0 is actually what we did which turns off caching. So by deleting the entry we are bringing it back to its original state.
Your script worked perfectly again. Thank you very much. I'm sure you can guess how much time you saved me now and in the future. It's very easy to learn from example.

John

Top
#152682 - 2005-12-14 03:13 AM Re: Working within Documents and Settings
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
You're quite welcome. I know how you feel. I too like seeing an example.
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 525 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.077 seconds in which 0.036 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