Page 1 of 1 1
Topic Options
#110663 - 2003-12-19 05:33 PM Delprof using Kixtart
cmarti Offline
Hey THIS is FUN

Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
How can I get the delprof.exe(deletes profles, from the 2k resource kit) to run using kix. I've tried all of the following:
Code:

Shell '%Comspec% /c Delprof /d:90'
Shell '%Comspec% /c Delprof /?'
Shell '%Comspec% /c Delprof'
Shell 'Delprof'
Shell '%Comspec% /c "Delprof /d:90"'



No matter what I use they all return with this...
Delete inactive profiles on \\MyMachineName (Yes/No)

When I run the command straight from dos it runs ok and prompts to delete profiles unused for x days. It seems as if none of the arguments are being passed to the delprof command. I'm running kix 4.02 on windows 2k sp3.

Thanks in advance...

Top
#110664 - 2003-12-19 05:54 PM Re: Delprof using Kixtart
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
This works for me.

Code:
 shell "delprof /d:90" 

_________________________
Eric

Top
#110665 - 2003-12-19 06:07 PM Re: Delprof using Kixtart
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Maybe try specifying the full path to delprof.exe?
Top
#110666 - 2003-12-19 06:08 PM Re: Delprof using Kixtart
cmarti Offline
Hey THIS is FUN

Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
Thanks, but I've already tried that, it didn't work either. This will be running on a terminal server, does that matter?
Top
#110667 - 2003-12-19 06:17 PM Re: Delprof using Kixtart
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
The following works fine for me...On WinXP Pro Machine. Will try it on a Term Server and let you know what I get.

Code:
$null = SetOption ("WrapAtEOL","On")
Shell 'delprof /D:90'
? "Press Any Key To Continue"
get $null


Top
#110668 - 2003-12-19 06:23 PM Re: Delprof using Kixtart
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
It also worked as expected on Win2000 server with TS and Citrix. What version of DelProf are you using? I have 5.2.3790.0.
Top
#110669 - 2003-12-19 06:28 PM Re: Delprof using Kixtart
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Why not do it with KiXtart:
Code:

$maxprofileage=20
$profilelist=$HKLM+'\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'
$profiles=arrayenumkey($profilelist)

for each $usersid in $profiles
if $usersid<>'' and right($usersid,4)<>'-500'
$username=sidtoname($usersid)
$username=right($username,len($username)-instrrev($username,'\'))
if $username=''
$username='account unknown: '+$usersid
endif
$profiledir=expandenvironmentvars(readvalue($profilelist+'\'+$usersid,'ProfileImagePath'))
if $profiledir<>''
$userprofiles=dirlist($profiledir+'.*',1)
for each $userprofile in $userprofiles
$profiledate=getfiletime($userprofile+'\ntuser.dat')
$profiledate=left($profiledate,10)
if datemath($profiledate,@DATE)>$maxprofileage
$shellcommand='rd /s /q '+$userprofile
shell '%COMSPEC% /c '+$shellcommand
if $userprofile=$profiledir
$retcode=delkey($profilelist+'\'+$usersid)
endif
endif
next
endif
endif
next

_________________________
There are two types of vessels, submarines and targets.

Top
#110670 - 2003-12-19 06:45 PM Re: Delprof using Kixtart
cmarti Offline
Hey THIS is FUN

Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
CitrixMan, my version was lower than yours so I downloaded the newest version from Microsoft's site. Now I'm running verion 5.2.3790.1060.

Here's what I get on my screen:

E:\>type test.scr
shell '\\cmarti2ksrv\e$\Delprof /d:20'
E:\>kix32 test.scr

Delete inactive profiles on \\CMARTI2KSRV? (Yes/No) n

Nothing deleted.


E:\>delprof /d:20

Delete profiles on \\CMARTI2KSRV that have not been used in the last 20 days? (Y
es/No) n

Nothing deleted.


E:\>


Check out the difference in the output betwen running it from a script and running the delprof command from the command line. I only want to delete unused profiles older than 20 days...

Sealeopard,
Thanks for the code. I hadn't tried to delete the profile through kix because I didn't know what all it involved.

Thanks..

Top
#110671 - 2003-12-19 07:03 PM Re: Delprof using Kixtart
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
The principle is to enumerate all profiles on the computer. Then discard all local profiles and the admin profiles (SID ends with -500). Then use the user registry hive file NTUSER.DAT to check when it was last accessed. Calculate the difference between that date and today to see whether the profile is above the delete-threshold. Then delete the profile directory and remove the appropriate registry key.
_________________________
There are two types of vessels, submarines and targets.

Top
#110672 - 2003-12-19 07:37 PM Re: Delprof using Kixtart
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Pure kix will certainly work...I am just a bit curious/confused as to why the delprof.exe does not work. What version of Kix are you running (it worked with both kix32.exe and wkix32.exe ver 4.22 on mine)? And have you tried it on multiple machines or just the one.
Top
#110673 - 2003-12-19 07:40 PM Re: Delprof using Kixtart
cmarti Offline
Hey THIS is FUN

Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
I'm running kix 4.02, I've also tried using 4.22. I've also tried it on 3 different machines and get the same output...
Top
#110674 - 2003-12-19 09:02 PM Re: Delprof using Kixtart
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Could it be because you are running it from/against a remote UNC path?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#110675 - 2003-12-19 09:25 PM Re: Delprof using Kixtart
cmarti Offline
Hey THIS is FUN

Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
I've tried running it from the local machine and it doesn't work either. In my very first post of this thread was how I was running it..
Top
#110676 - 2003-12-20 06:43 AM Re: Delprof using Kixtart
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
If you are interested.. Here is a variation of this that I have talked about recently - Re: Citrix Clean up script

It should be pretty simple to modify to what you need.

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

Top
#110677 - 2004-07-09 11:44 AM Re: Delprof using Kixtart
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
Bit late this, but never mind.

How will the pure KiX soloution remove special folders such as the recyclebin? As far as I can see it only deletes the profiles sub folder for a user.

Although it's a nice bit of code I just don't think it will work as well as delprof.

I use :
Code:

;===============================================================================================
; delprof.kix
; Last Modified on 21/01/04 at 13:59:52 by acmp
;===============================================================================================

;tidy up profiles on remote PC

;Change Log:-
;21/1/04 Set exit to be when no information is entered rather than prompt and Loop
;21/1/04 Put logging into main IF loop so that it only applies when the process runs OK

Break on

;splash
Big
Color w+/n
?" DelProf!"
Sleep(1)
;Header
Small
CLS
Box(1,1,10,40,"double")
At(2,9)"Profile tidyup by acmp"
At(3,9)"======================"
Color w/n
At(5,4)"Enter a PC name to tidy up."
At(6,4)"This program uses delprof from the"
At(7,4)"NT RES Kit, located in efolders"
At(8,4)"Results are logged in delprof.log"

At(11,1)
:Loop
?"Enter the PC name you wish to tidy (Or [Return] to quit)"@CRLF
Gets $pc

If Asc($pc)<>0
;If $pc<>asc(0)
$pc=Trim($pc)
$free=pipe("dir \\$pc\admin$")
For Each $line In $free
If InStr ($line,"bytes free")
?Trim($line) +" Before delprof"
$splitted=Split(Trim($line)," ",1)
For Each $element In $splitted
$before=$element
Next
EndIf
Next

$status=Pipe("\\server13\efolders\delprof.exe /q /i /c:\\$pc")

For Each $line In $status
?$line
Next

$free=pipe("dir \\$pc\admin$")
For Each $line In $free
If InStr ($line," bytes free")
?Trim($line) +" After delprof"
$splitted=Split(Trim($line)," ",1)
For Each $element In $splitted
$after=$element
Next
EndIf
Next
$entry=$pc+",'"+$before+"','"+$after+"',"+@USERID
writelog2("\\server13\netapps\KixLogs\delprof.log",$entry,1)
Else
Exit
EndIf

?""
?"done"
GoTo("Loop")

Function pipe($command)
;$array = pipe("net users") ; load output of net users into an array
;$array = pipe("dir c:\*.ini /s /b") ; load a listing of all ini files into an array
;$array = pipe("type config.txt") ; load the contents of a text file into an array
;$ipconfig = pipe('ipconfig /all | find "Server"')
;For Each $line In $ipconfig
; ? $line
;Next
Dim $i,$error,$line
Dim $array[255]
Dim $ReDim $ReDim = Ubound($array)
Dim $tempfile $tempfile = "%temp%\pipe.tmp"
If Exist("$tempfile")
Del("$tempfile")
EndIf
If @inwin = 2 ; win9x
Shell '%comspec% /c $command >"$tempfile"'
Else ; winnt
Shell '%comspec% /c $command >"$tempfile" 2>nul'
EndIf
$error=@error
If Open(10,"$tempfile") = 0
$i=0
$line = ReadLine(10)
While NOT @error
If $line
$array[$i] = $line
If $i = $ReDim
$ReDim=$ReDim*2
ReDim preserve $array[$ReDim]
EndIf
$i=$i+1
EndIf
$line = ReadLine(10)
Loop
$=Close(10)
Del "$tempfile"
If $i > 0
ReDim preserve $array[$i-1]
$pipe=$array
Else
$pipe = 0
EndIf
Exit $error
Else
$pipe = 0
Exit @error
EndIf
EndFunction

Function WriteLog2($File, $Text, optional $TimeStamp)
;WriteLog2($File, $text, [0|1])

Dim $RC, $File, $text, $FH, $TimeStamp
$FH=1
$RC=Open ($FH, $File, 5)
While $RC = -3
$FH=$FH +1
$RC=Open ($FH, $File, 5)
Loop
Select
Case $RC=0
If ($TimeStamp=1)
$TimeStamp = "," +@Date + "," + @Time
Else
$TimeStamp = ""
EndIf
$RC=WriteLine ($FH, $Text + $TimeStamp+ @CRLF)
$RC=Close ($FH)
Case $RC=-2
$text = "WriteLog2: Invalid file handle ($FH) specified when trying to Open $File."
;$RC=MessageBox ($text,"Script Error",48)
Case $RC=-1
$text = "WriteLog2: Invalid file name ($File) specified for log file."
;$RC=MessageBox ($text,"Script Error",48)
Case $RC=>0
$text = "System Error($RC) while attempting to open log file ($File)."
;$RC=MessageBox ($text,"Script Error",48)
EndSelect
EndFunction



I have it packaged with KixStart and just run it from a shortcut and it is brill.

acmp<><
_________________________
Every day is a school day

Top
#110678 - 2006-01-20 01:05 PM Re: Delprof using Kixtart
Christopher Hill Offline
Fresh Scripter

Registered: 2001-12-11
Posts: 5
Loc: Colchester, Essex, UK
Quote:

How can I get the delprof.exe(deletes profles, from the 2k resource kit) to run using kix...

No matter what I use they all return with this...
Delete inactive profiles on \\MyMachineName (Yes/No)

When I run the command straight from dos it runs ok and prompts to delete profiles unused for x days. It seems as if none of the arguments are being passed to the delprof command. I'm running kix 4.02 on windows 2k sp3.

Thanks in advance...




This is probably waaay too late for the original poster, but I've just run into the same problem and just in case someone else needs the solution:

delprof will do this if you run it as 'Delprof.exe' instead of 'delprof.exe' (notice the case!) So make sure that your script runs 'delprof.exe' ALL in lower case and you should be OK.

Strange but true...

Top
#110679 - 2006-01-20 09:24 PM Re: Delprof using Kixtart
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
This is how it works
Code:

Run "@lserver\netlogon\delprof.exe /Q /D:90"



the /Q makes it quiet, and won't ask for Y/N
(I've been using this for over a year now on clients and terminal servers)

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
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.067 seconds in which 0.024 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