Page 1 of 2 12>
Topic Options
#188353 - 2008-06-25 04:44 PM Run command against multiple user profiles
Zactek Offline
Fresh Scripter

Registered: 2008-06-25
Posts: 12
Essentially, I am trying to run a command through a KIX login script that will run a utility that can delete a specific entry from the NK2 file. This utility is called NK2View. You can use switches from the command line to perform a delete of a record within the NK2 file upon login.

 Code:
nk2view.exe /delete username@domain.com 


I have researched on this and other forums different ways to try and do this, but I have only found code to delete the entire file itself. This example is from a post from NTDOC -
 Code:
$nk2=ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'AppData')
If Exist($nk2+'\Microsoft\Outlook\*.nk2')=1  
;Searches for files ending with .NK2 and deletes them.  
Del($nk2+'\Microsoft\Outlook\*.nk2')EndIf 


Another one of the challenges is also trying to get this to apply to users that are have Windows XP and Vista because the paths are different. I need to get this to run upon logon, so I probably don't need to feed in a list of computer names, but I do need to run this utility remotely against multiple user's computers and multiple profiles. Also, I may have 2 paths because some are still on XP with different versions of Outlook -

 Code:
 [b]Outlook 2000 / 2003 / 2007[/b] - \\%computername%\C$\Documents and Settings\%userprofile%\Application Data\Microsoft\Outlook\outlook.nk2

[b]Microsoft Vista with Outlook[/b] - \\%computername%\C$\Users\%userprofile%\AppData\Roaming\Microsoft\Outlook\outlook.nk2


Anyhow, any help is appreciated.

Top
#188354 - 2008-06-25 04:50 PM Re: Run command against multiple user profiles [Re: Zactek]
Kdyer Offline
KiX Supporter
*****

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

You should be able to use %APPDATA% as the variable. Just went to a command prompt and typed in SET to see what Environment Variables are available.

Also, you could do this from the Registry:
 Code:
$AppData = READVALUE('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders','AppData')

This is also included in Doc's code. Probably the easiest way to do this is at login. Sure, you could do this remotely, but will be more difficult.

HTH,

Kent


Edited by Kdyer (2008-06-25 04:53 PM)
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#188357 - 2008-06-25 05:02 PM Re: Run command against multiple user profiles [Re: Kdyer]
Zactek Offline
Fresh Scripter

Registered: 2008-06-25
Posts: 12
Kent,

What about if I want to backup / change the existing to a backup (e.g. *.bak) and then execute this utility? I'm trying to get a fuller example of how I could do this. Any help is appreciated!

Thank You,
Zactek


Edited by Zactek (2008-06-25 05:03 PM)

Top
#188395 - 2008-06-26 04:50 PM Re: Run command against multiple user profiles [Re: Zactek]
Zactek Offline
Fresh Scripter

Registered: 2008-06-25
Posts: 12
This is essentially what I am trying to do within the KiXtart script, but at the command line it is returning a value of zero (0) :

 Code:
Dim $ServerName, $nk2, $ProfilePath, $SearchString, $SharePath, $ProgramPath, $CmdString, $RunLine, $CmdLine	
;
;Edit Variables
;
$ServerName = 
;For example $ServerName = "Server1" or "Server1.yourdomain.com"
$nk2 = ReadValue('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'AppData')
$ProfilePath = $nk2+"\Microsoft\Outlook\"
;For example $ProfilePath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2", or "Null"
$SearchString = 
;
;-------------------------------------------------------------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------------------------------------------------------------
$SharePath = "\\" + $ServerName + "\nk2view\"
$ProgramPath = $SharePath + "nk2view.exe"

;This section fills in the default NK2 path
If $ProfilePath = "Null"
	$ProfilePath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2"
EndIf

If Exist($nk2+'\Microsoft\Outlook\*.bak*')=1
;Searches for files ending with .BAK and that may have anything appended and then stops script if condition is true
	Goto EOF
EndIf

If Exist($nk2+'\Microsoft\Outlook\*.nk2')=1  
;Searches for files ending with .NK2 and creates backup.  
	Move($nk2+'\Microsoft\Outlook\*.nk2') ($nk2+'\Microsoft\Outlook\*.bak+@YEAR+@MONTHNO+@MDAYNO+@TIME')
EndIf

$CmdString = $ProgramPath + "/nk2file " + $ProfilePath

:SearchDelete
$Runline = $CmdString + " /delete " + $SearchString
GoTo CmdLine

:CmdLine
 Shell $Runline

:EOF
Exit
Exit

Top
#188402 - 2008-06-26 06:45 PM Re: Run command against multiple user profiles [Re: Zactek]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
One thing that pops in to my mind is trying to read in the local user's information if you are to run this Remotely. It is pretty easy to do a READVALUE remotely on HKLM, but HKCU is more painful from an Admin side as you have to know the SID..

I did clean up your code a bit too.
 Code:
 DIM $servername, $nk2, $profilepath, $searchstring, $sharepath, $programpath, $cmdstring, $runline, $cmdline
 ;
 ;Edit Variables
 ;
 $servername = @lserver
 ;For example $ServerName = "Server1" or "Server1.yourdomain.com"
 $nk2 = ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'AppData')
 $profilepath = $nk2+"\Microsoft\Outlook\"
 ;For example $ProfilePath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2", or "Null"
 $searchstring =
 ;-------------------------------------------------------------------------------------------------------------------------------------------
 ;-------------------------------------------------------------------------------------------------------------------------------------------
 $sharepath = "\\" + $servername + "\nk2view\"
 $programpath = $sharepath + "nk2view.exe"

 ;This section fills in the default NK2 path
 IF NOT EXIST($profilepath)
       $profilepath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2"
 ENDIF

 IF EXIST($nk2+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME)
       RETURN ; RETURN maybe better than EXIT as RETURN takes you back to where left off
 ENDIF

 IF EXIST($nk2+'\Microsoft\Outlook\*.nk2')
       ;Searches for files ending with .NK2 and creates backup.
       MOVE $nk2+'\Microsoft\Outlook\*.nk2' $nk2+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME
       $cmdstring = $programpath + "/nk2file " + $profilepath
       $runline = $cmdstring + " /delete " + $searchstring
       SHELL $runline
 ENDIF


HTH,

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

Top
#188408 - 2008-06-26 09:16 PM Re: Run command against multiple user profiles [Re: Kdyer]
Zactek Offline
Fresh Scripter

Registered: 2008-06-25
Posts: 12
Kent,

Does the @lserver macro include the double backslashes in its output? Also, if I wanted to run this for multiple iterations, I may want to name the *.BAK files with a unique variable and possibly delete older variables. Do you have any other suggestions for something like this? Thanks for all of your help!

Thank You,
Zach Crawford

Top
#188409 - 2008-06-26 09:32 PM Re: Run command against multiple user profiles [Re: Zactek]
Zactek Offline
Fresh Scripter

Registered: 2008-06-25
Posts: 12
\:\( - I'm still not able to getting this to work. The KiX debug hasn't been that helpful. Here is the tool that I am trying to use - NK2View

Here is the exact code that I am trying to run:

 Code:
DIM $servername, $nk2, $profilepath, $searchstring, $sharepath, $programpath, $cmdstring, $runline, $cmdline
 ;
 ;Edit Variables
 ;
 $servername = ho00060lp57
 ;For example $ServerName = "Server1" or "Server1.yourdomain.com"
 $nk2 = ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'AppData')
 $profilepath = $nk2+"\Microsoft\Outlook\"
 ;For example $ProfilePath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2", or "Null"
 $searchstring = "zactek@msn.com"
 ;-------------------------------------------------------------------------------------------------------------------------------------------
 ;-------------------------------------------------------------------------------------------------------------------------------------------
 $sharepath = "\\" + $servername + "\nk2view\"
 $programpath = $sharepath + "nk2view.exe"

 ;This section fills in the default NK2 path
 IF NOT EXIST($profilepath)
       $profilepath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2"
 ENDIF

 IF EXIST($nk2+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME)
       RETURN ; RETURN maybe better than EXIT as RETURN takes you back to where left off
 ENDIF

 IF EXIST($nk2+'\Microsoft\Outlook\*.nk2')
       ;Searches for files ending with .NK2 and creates backup.
       MOVE $nk2+'\Microsoft\Outlook\*.nk2' $nk2+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME
       $cmdstring = $programpath + "/nk2file " + $profilepath
       $runline = $cmdstring + " /delete " + $searchstring
       SHELL $runline
 ENDIF


The only thing that I changed was using my local computer name and my personal e-mail address in the $searchString. There is a share on my computer that I have rights to with the name of "nk2view".

Top
#188411 - 2008-06-26 10:24 PM Re: Run command against multiple user profiles [Re: Zactek]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
OK.. I think we need to revisit a couple of things here..

You are doing a MOVE, which means that you are taking a file and moving it to another name. So, how can nk2view act on the file when it is renamed or moved to another name?

Debugging is a cinch in KiX.. You can initiate a debug on in your script.. You can then look at the resulting @error and @serror macros to see what is going on.

Also, you can do kix32 /d yourscript.kix

This stuff is discussed in the FAQ Forum..

So.. Here is what I have put together so far (still not working, but closer):

 Code:
BREAK ON
CLS
DIM $servername, $nk2, $profilepath, $searchstring, $sharepath, $programpath, $cmdstring, $runline, $cmdline
 ;
 ;Edit Variables
 ;
 $servername = ho00060lp57
 ;For example $ServerName = "Server1" or "Server1.yourdomain.com"
 $AppD = ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'AppData')
 ???$AppD
 $profilepath = $AppD+"\Microsoft\Outlook\"
 ;For example $ProfilePath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2", or "Null"
 $searchstring = "test@test.com"
 ;-------------------------------------------------------------------------------------------------------------------------------------------
 ;-------------------------------------------------------------------------------------------------------------------------------------------
 $sharepath = @scriptdir + "\"
 ;$sharepath = "\\" + $servername + "\nk2view\"
 $programpath = $sharepath + "nk2view.exe"

 ;This section fills in the default NK2 path
 IF NOT EXIST($profilepath)
       $profilepath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2"
 ENDIF

 IF EXIST($AppD+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME)
       RETURN ; RETURN maybe better than EXIT as RETURN takes you back to where left off
 ENDIF

 IF EXIST($AppD+'\Microsoft\Outlook\*.nk2')
       ;Searches for files ending with .NK2 and creates backup.
       ; -- You want to do a copy to backup before messing with the file...
       debug on
       ???'"'+$profilepath+'*.NK2'+'"'
       CD $profilepath
       COPY '"'+'*.NK2'+'"' '"'+'*.bak'+'"'
       ;COPY "MyDir\file*.txt" "MyDir\file*.bak"

       ???@SERROR+@ERROR
       ;MOVE $AppD+'\Microsoft\Outlook\*.nk2' $AppD+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME
       $cmdstring = $programpath + "/nk2file " + $profilepath
       $runline = $cmdstring + " /delete " + $searchstring
       SHELL $runline
 ENDIF

get $


HTH,

Kent


Edited by Kdyer (2008-06-26 10:57 PM)
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#188412 - 2008-06-26 10:55 PM Re: Run command against multiple user profiles [Re: Kdyer]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
OK.. Spent some time on this for you.. It now works..

 Code:
BREAK ON
CLS
DIM $servername, $nk2, $profilepath, $searchstring, $sharepath, $programpath, $cmdstring, $runline, $cmdline
 ;
 ;Edit Variables
 ;
 $servername = ho00060lp57
 ;For example $ServerName = "Server1" or "Server1.yourdomain.com"
 $AppD = ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'AppData')
 ???$AppD
 $profilepath = $AppD+"\Microsoft\Outlook\"
 ;For example $ProfilePath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2", or "Null"
; NOTE: Don't forget to double up the @@ for an e-mail address
 $searchstring = "test@@test.com"
 ;-------------------------------------------------------------------------------------------------------------------------------------------
 ;-------------------------------------------------------------------------------------------------------------------------------------------
 $sharepath = "c:\!KIX\"
 ;$sharepath = "\\" + $servername + "\nk2view\"
 $programpath = $sharepath + "nk2view.exe"

 ;This section fills in the default NK2 path
 IF NOT EXIST($profilepath)
       $profilepath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2"
 ENDIF

 IF EXIST($AppD+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME)
       RETURN ; RETURN maybe better than EXIT as RETURN takes you back to where left off
 ENDIF

 IF EXIST($AppD+'\Microsoft\Outlook\*.nk2')
       ;Searches for files ending with .NK2 and creates backup.
       ; -- You want to do a copy to backup before messing with the file...
       ; -- You may also do a check to insure Outlook is closed before proceeding
       debug on
       SHELL '%COMSPEC% /C COPY "'+$profilepath+'*.NK2" "'+$profilepath+'*.bak"'
       ;COPY "MyDir\file*.txt" "MyDir\file*.bak"

       ???@SERROR+@ERROR
       ;MOVE $AppD+'\Microsoft\Outlook\*.nk2' $AppD+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME
       ; NOTE: You may run into a problem with multiple nk2 files...  '*.NK2"'
       $cmdstring = $programpath + ' /nk2file "' + $profilepath+'*.NK2"'
       ?$cmdstring
       $runline = $cmdstring + ' /delete ' + $searchstring
       ?$RUNLINE
       SHELL $runline
       ???@SERROR+@ERROR
 ENDIF

get $


HTH,

Kent


Edited by Kdyer (2008-06-26 10:57 PM)
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#188413 - 2008-06-26 11:18 PM Re: Run command against multiple user profiles [Re: Kdyer]
Zactek Offline
Fresh Scripter

Registered: 2008-06-25
Posts: 12
Kent,

Thanks for all of your work on this. I'm not sure if there was a question on the $AppD but it's supposed to read in that system setting for %AppData%. I'm hoping that I clearly explained what I'm trying to accomplish with this script.

Thank You,
Zach Crawford

Top
#188414 - 2008-06-26 11:47 PM Re: Run command against multiple user profiles [Re: Zactek]
Zactek Offline
Fresh Scripter

Registered: 2008-06-25
Posts: 12

Kent,
It looked like that it copied the file and made the *.bak, but the application that I am using didn't delete the entry from the NK2 file even when I used "zactek@@msn.com" in the $searchString variable. Also, is there a way to append a unique value to the end of the backup file? I was initially thinking like date/time and then try to delete any backup files that were before that iterations date/time if we ran this multiple times. It's time for the MountainDew for me...

Thanks for all your help!
Zach

Top
#188429 - 2008-06-27 04:16 PM Re: Run command against multiple user profiles [Re: Zactek]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Hang tight.. I am going to look at something a bit different for you.

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

Top
#188431 - 2008-06-27 04:41 PM Re: Run command against multiple user profiles [Re: Kdyer]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
OK.. Got it.. Need to use the following UDF: WSHPIPE.

Here is the code..

 Code:
BREAK ON
CLS
DIM $servername, $nk2, $profilepath, $searchstring, $sharepath, $programpath, $cmdstring, $runline, $cmdline
 ;
 ;Edit Variables
 ;
 $servername = ho00060lp57
 ;For example $ServerName = "Server1" or "Server1.yourdomain.com"
 $AppD = ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'AppData')
 ???$AppD
 $profilepath = $AppD+"\Microsoft\Outlook\"
 ;For example $ProfilePath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2", or "Null"
 $searchstring = "you@@domain.com"
 ;-------------------------------------------------------------------------------------------------------------------------------------------
 ;-------------------------------------------------------------------------------------------------------------------------------------------
 $sharepath = "c:\!KIX\"
 ;$sharepath = "\\" + $servername + "\nk2view\"
 $programpath = $sharepath + "nk2view.exe"

 ;This section fills in the default NK2 path
 IF NOT EXIST($profilepath)
       $profilepath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2"
 ENDIF

 IF EXIST($AppD+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME)
       RETURN ; RETURN maybe better than EXIT as RETURN takes you back to where left off
 ENDIF

 IF EXIST($AppD+'\Microsoft\Outlook\*.nk2')
       ;Searches for files ending with .NK2 and creates backup.
       ; -- You want to do a copy to backup before messing with the file...
       ;;debug on
       ??$profilepath
       ;;SHELL '%COMSPEC% /C COPY "'+$profilepath+'*.NK2" "'+$profilepath+'*.bak"'
       ;COPY "MyDir\file*.txt" "MyDir\file*.bak"

       ; -- LOOK FOR NK2 FILES

       ???@SERROR+@ERROR
       ;MOVE $AppD+'\Microsoft\Outlook\*.nk2' $AppD+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME
       ; NOTE: You may run into a problem with multiple nk2 files...  '*.NK2"'

       $rc=WshPipe('%comspec% /c dir /b "'+$profilepath+'*.NK2"',1) 
       for each $line in $rc 
           if not instr($line, "File Not Found") 
              ? $line 
              ;>>
              $cmdstring = $programpath + ' /nk2file "' + $profilepath+$line + '"'
              $runline = $cmdstring + ' /delete ' + $searchstring
              SHELL $runline
              ???@SERROR+@ERROR
           ;>>
           endif 
       next 
       @ERROR " | " @SERROR ? 
 ENDIF
?'Process is complete'
get $



HTH,

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

Top
#188439 - 2008-06-27 07:26 PM Re: Run command against multiple user profiles [Re: Kdyer]
Zactek Offline
Fresh Scripter

Registered: 2008-06-25
Posts: 12

Kent,

When I tried to execute from the command line, but I got -

The operation completed successfully.0
ERROR : expected ')'!
Script: C:\NK2View\nk2view_new.kix
Line : 43

The only change that I made was to use my computer and path. This appears to be the line for the start of your WshPipe UDF.

Thank You,
Zach Crawford

Top
#188440 - 2008-06-27 07:29 PM Re: Run command against multiple user profiles [Re: Zactek]
Kdyer Offline
KiX Supporter
*****

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

Note the link for the WSHPIPE UDF above. You will need to go copy/paste that into the script as it is a separate "User Defined Function".

BTW, it is not my script. \:D

HTH,

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

Top
#188442 - 2008-06-27 08:31 PM Re: Run command against multiple user profiles [Re: Kdyer]
Zactek Offline
Fresh Scripter

Registered: 2008-06-25
Posts: 12
Kent,

I did see that Chris had his initial posting, but then it looks like a later update to the code was on his #83231 - 04/02/13 07:52 PM Posting. Is this is the one that I should be using within the code?

Thanks!
Zach

Top
#188443 - 2008-06-27 08:45 PM Re: Run command against multiple user profiles [Re: Zactek]
Zactek Offline
Fresh Scripter

Registered: 2008-06-25
Posts: 12
\:\)
Kent,

I added the UDF code from that post I mentioned and the executable ran successfully and deleted the NK2 file entry. Now I need some help on the copy, move, rename of the file. Basically the intent of the script is to check to see if there are any *.bak files in the %APPDATA%\Microsoft\Outlook\ folder and if not, create a copy of the file and rename it to *.bak with appended information and then run an application that is used to remove an entry from the original NK2 file. I am also looking for a way to get all NK2 files, back them up and then run this utility against the original. I am not sure if something like this would help get around some of the technical challenges of getting "everything".

 Code:
$PrfName = ReadValue ("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles","DefaultProfile")
$nk2 = "%APPDATA%\Microsoft\Outlook\" + $prfname + ".nk2"


I appreciate yours and anyone else's help on this!
Thank You,
Zach Crawford

Top
#188445 - 2008-06-27 09:53 PM Re: Run command against multiple user profiles [Re: Zactek]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
 Originally Posted By: Zactek
Kent,

I did see that Chris had his initial posting, but then it looks like a later update to the code was on his #83231 - 04/02/13 07:52 PM Posting. Is this is the one that I should be using within the code?

Thanks!
Zach


Zach - Any UDF that is posted: You should used the UDF from the initial post and that is it. If there are modifications to a UDF, people usually PM the Author and as needed, changes made to the initial post of the UDF.

HTH,

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

Top
#188447 - 2008-06-27 10:30 PM Re: Run command against multiple user profiles [Re: Kdyer]
Kdyer Offline
KiX Supporter
*****

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

(1) The WSHPIPE UDF gives you a facility to look for each file that exists in a user profile, back up the file, act on it and then go to the next.

(2) I would become familiar with the UDF Libarary (it is your KiXtart friend!)..
UDF Libary

The UDF Libary in the discussion forum is a bit cumbersome for navigation to put together a list of UDFs and if you read the first post from NTDOC, he explains about the parsed out list of UDFs with an included search tool as well.
UDF Library Collection Sites - Sorted List of UDF

http://www.kixtart.org/UDF is the whole collection of UDFs.

Hmm.. Check this out.. This may help in enumerating profiles remotely.
Profile list


Thanks,

Kent


Edited by Kdyer (2008-06-27 11:12 PM)
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#188481 - 2008-06-30 03:45 PM Re: Run command against multiple user profiles [Re: Kdyer]
Zactek Offline
Fresh Scripter

Registered: 2008-06-25
Posts: 12
Kent,

I appreciate you pointing out some more of the resources on KiXtart website. I am just unsure about the first statement in your post because I don't know exactly how to use it to copy / backup each NK2 file within that function. This is the code that I have where it does run the application I'm using, but it doesn't copy / backup the NK2 file. When I do the backup, I need to find a way to append a unique value to the end of the file extension (e.g. Outlook.NK2_A1). I want to copy this file to another location (e.g. %SYSTEMDRIVE%\alfascript\ ) Any more help is appreciated!

 Code:
BREAK ON
CLS
DIM $servername, $nk2, $profilepath, $searchstring, $sharepath, $programpath, $cmdstring, $runline, $cmdline
 ;
 ;Edit Variables
 ;
 $servername = ho00060lp57
 ;For example $ServerName = "Server1" or "Server1.yourdomain.com"
 $AppD = ReadValue ("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles","DefaultProfile")
 $profilepath = $AppD+"\Microsoft\Outlook\"
 ;For example $ProfilePath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2", or "Null"
 $searchstring = "zactek@@msn.com"
 ;-------------------------------------------------------------------------------------------------------------------------------------------
 ;-------------------------------------------------------------------------------------------------------------------------------------------
 $sharepath = "\\" + $servername + "\nk2view\"
 $programpath = $sharepath + "nk2view.exe"

 ;This section fills in the default NK2 path
 IF NOT EXIST($profilepath)
       $profilepath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2"
 ENDIF

 IF EXIST($AppD+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME)
       RETURN ; RETURN maybe better than EXIT as RETURN takes you back to where left off
 ENDIF

 IF EXIST($AppD+'\Microsoft\Outlook\*.nk2')
       ;Searches for files ending with .NK2 and creates backup.
       ; -- You want to do a copy to backup before messing with the file...
       ;;debug on
       ??$profilepath
       ;;SHELL '%COMSPEC% /C COPY "'+$profilepath+'*.NK2" "'+$profilepath+'*.bak"'
       ;COPY "MyDir\file*.txt" "MyDir\file*.bak"

       ; -- LOOK FOR NK2 FILES

       ???@SERROR+@ERROR
       COPY $AppD+'\Microsoft\Outlook\*.nk2' $AppD+'\Microsoft\Outlook\*.bak'
       ; NOTE: You may run into a problem with multiple nk2 files...  '*.NK2"'
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
   Dim $oExec, $Output	
   $oExec = CreateObject("WScript.Shell").Exec($ShellCMD)	
   If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
   $Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
   If Not $NoEcho $Output Endif	
   $WshPipe=Split(Join(Split($Output,CHR(13)),''),CHR(10))
   Exit($oExec.ExitCode)
EndFunction
	 $rc=WshPipe('%comspec% /c dir /b "'+$profilepath+'*.NK2"',1) 
       for each $line in $rc 
           if not instr($line, "File Not Found") 
              ? $line 
              ;>>
              $cmdstring = $programpath + ' /nk2file "' + $profilepath+$line + '"'
              $runline = $cmdstring + ' /delete ' + $searchstring
              SHELL $runline
              ???@SERROR+@ERROR
           ;>>
           endif 
       next 
       @ERROR " | " @SERROR ? 
 ENDIF
?'Process is complete'
get $

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.077 seconds in which 0.025 seconds were spent on a total of 14 queries. Zlib compression enabled.

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