Page 1 of 1 1
Topic Options
#21011 - 2002-05-01 05:45 PM Roaming Profile Cleanup
Anonymous
Unregistered


Most of my user's move around to various workstations so I use roaming profiles in a (mostly) NT environment. I want to do some cleanup when the user logs off such as deleting temporary internet files and cookies. Is there a way to do this through the logon script or should I look into possible doing it through policies? Any suggestions are appreciated.

[Wink]

Top
#21012 - 2002-05-01 06:08 PM Re: Roaming Profile Cleanup
Kdyer Offline
KiX Supporter
*****

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

This is using GETVAR from http://win-scripts.com - download area.

Here is what we use to clean out bogus profiles in Citrix. It is not a Kix solution, but should help.

code:
@echo off
IF EXIST "%TEMP%\%USERNAME%.BAT" DEL "%TEMP%\%USERNAME%.BAT"
::%0\..\GETVAR.EXE -v FN -f %TEMP%\%USERNAME%.BAT "Enter a UserID:"
\\SERVER\utility\GETVAR.EXE -v FN -f %TEMP%\%USERNAME%.BAT "Enter a UserID: "
@echo on

CALL "%TEMP%\%USERNAME%.BAT"

set zInput=%FN%

@echo off
ECHO WE ARE GOING TO REMOVE CITRIX_HOMEDIR FOR %zInput%
@echo on
PAUSE
PUSHD \\SHARSERVER\citrix_homedir\%zInput%
If not errorlevel 1 goto :CitrixHomedir
If errorlevel 1 echo \\SHARESERVER\Citrix_Homedir\%zInput% was not found && goto :CitrixProf
:CitrixHomedir
IF EXIST \\SHARESERVER\Citrix_Homedir\%zInput%\. DEL /q \\SHARESERVER\Citrix_Homedir\%zInput%\*.*
FOR /F "Tokens=*" %%i in ('DIR /B') DO RD /s /q "%%i"
::UNDO THE DRIVE
POPD
:CitrixProf
@echo off
ECHO WE ARE GOING TO REMOVE CITRIX_PROFILES FOR %zInput%
PAUSE
@echo on
PUSHD \\SHARESERVER\Citrix_Profiles\%zInput%
If not errorlevel 1 goto :CitrixProfiles
If errorlevel 1 echo \\SHARESERVER\Citrix_Profiles\%zInput% was not found && goto :eof
:CitrixProfiles
IF EXIST \\SHARESERVER\Citrix_Profiles\%zInput%\. DEL /q \\SHARESERVER\Citrix_Profiles\%zInput%\*.*
FOR /F "Tokens=*" %%i in ('DIR /AD /B') DO ATTRIB -H -S /s /D "%%i"
FOR /F "Tokens=*" %%i in ('DIR /B') DO RD /s /q "%%i"
POPD

if exist %zInputTmp% del %zInput% >NUL

@echo off
ECHO Let's Clean the profiles on the servers
PAUSE
::for %%a in (1 2 3 4 5 6 7 8 9 10 11) do call :TestPad %%a
@echo on
FOR /L %%a in (1,1,11) do call :TestPad %%a
goto :EOF

:TestPad
set Padded=%1
for %%a in (%Padded%) do set pad=00%%a
::echo %Pad%
set Padded=%Pad:~1,2%
If %Pad:~2,3% GTR 9 Set Padded=%Pad:~2,2%

PING CITRIXSERVER%Padded% -n 1 | find "TTL"
IF %errorlevel% EQU 1 goto :EOF
::If not exist \\CITRIXSERVER%Padded%\ADMIN$\PROFILES\* goto :EOF
PUSHD \\CITRIXSERVER%Padded%\ADMIN$\PROFILES
for /f "Tokens=*" %%i in ('dir %zInput%.* /B') do rd /s /q "%%i"
POPD

goto :CHK

:CHK
pause

goto :EOF
:EOF

HTH,

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

Top
#21013 - 2002-05-02 10:04 AM Re: Roaming Profile Cleanup
Ghost Offline
Starting to like KiXtart

Registered: 2000-09-14
Posts: 171
Here's my attempt at removing the stored profiles from the computers.

The whole script also removes unwanted applications (Messageing, audio gal, etc) and adds applications that are needed.

It also (sounds good) rebuilds the startmenu using a cache of icons stored on the network.

Anyway here's the bit your interested in, if you want the whole script, let me know.

code:
; The dir where the profiles are stored
$dir = "C:\Documents and Settings\"

cd $dir

COLOR g+/n
? "Round 1"
COLOR w+/n

gosub EmptyProfilesdir

COLOR g+/n
? "Round 2"
COLOR w+/n

; Run it twice, incase it missed anything
gosub EmptyProfilesdir




EXIT 1



;*******************************************************************
;EmptyProfilesDir - Remove the contents of the Profiles dir except the standard folders
;*******************************************************************

:EmptyProfilesdir

Dim $SubDir
$Filename = Dir("*.*")
While $Filename <> "" And @Error = 0
If SubStr( $Filename , 1 , 1) <> "."
If GetFileAttr( $Filename ) & 16
$SubDir = $Filename
if $subdir = "Administrator"
? "Cannot remove $subdir Directory." ?
else
if $subdir = "All Users"
? "Cannot remove $subdir Directory." ?
else
if $subdir = "bob"
? "Cannot remove $subdir Directory." ?
else
if $subdir = "Default User"
? "Cannot remove $subdir Directory." ?
else
CD $SubDir
GoSub EmptyProfilesdir
CD ".."
$Filename = Dir("*.*")
While $Filename <> $SubDir
$Filename = Dir()
Loop
if $subdir = "Administrator"
? "Cannot remove $subdir Directory." ?
else
if $subdir = "bob"
? "Cannot remove $subdir Directory." ?
else
if $subdir = "All Users"
? "Cannot remove $subdir Directory." ?
else
if $subdir = "Default User"
? "Cannot remove $subdir Directory." ?
else
COLOR r+/n
? " $subdir empty...Removing..."
rd $subdir
COLOR w+/n
"Done."
endif
endif
endif
endif
endif
endif
endif
endif

$Err = SetFileAttr( $SubDir , 128 )
Else
$Err = SetFileAttr( $Filename , 128 )
$Extension = SubStr( $Filename , Len($Filename) - 3 , 4 )
;Select
;Case $Extension = ".*"
Del $Filename
? " Deleting $Filename "
"Done."
;EndSelect
Endif
Endif
$Filename = Dir()
Loop

RETURN

Hope this helps

[Smile]

[ 02 May 2002, 10:05: Message edited by: Ghost ]
_________________________
Who are you? Who slips into my robot body and whispers to my ghost?

Top
#21014 - 2002-05-02 02:36 PM Re: Roaming Profile Cleanup
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
OOh, OOh, OOh,

Ghost,

I am interested in the "...removes unwanted applications (Messageing, audio gal, etc)..." part!! Can you post that?

Thanks,
Rocco
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#21015 - 2002-05-02 04:59 PM Re: Roaming Profile Cleanup
Ghost Offline
Starting to like KiXtart

Registered: 2000-09-14
Posts: 171
OK

Here goes

I adapted CJ's script to uninstall the applications via the reg settings, however, with the profile for the computer being mandatory, when the user installs applications the reg settings are lost when they log out.

So I setup the script to look for the program directory and remove it. Simple.

Here's CJ's script..

code:
  

; Uninstall Utility for Win32
; by cj
;
; This program reads the Uninstall information from the Registry and
; allows you to select a program to be uninstalled.
;
; Be careful and enjoy!
;
; cj
;

dim $programs[100] ; increase this if you have more than 100 installed apps
$base="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
$loud="UninstallString"
$quiet="QuietUninstallString"
$runstring=""
$disp=0

color w+/n "Unstallable Programs:" color w/n
$indexQ=0
while @error=0
$indexQ=$indexQ+1
$program=enumkey($base, $indexQ) ; get the next installed program's name

$=readvalue("$base\$program", $quiet) ; does it have the Quiet Uninstall?
if @error=0 ; YES
$disp=$disp+1 ? if $disp<10 " " endif
"$disp - Quiet Uninstall: $program"
$programs[$disp]="$program" ; store its name for later
endif

$=readvalue("$base\$program", $loud) ; Does it have the loud install?
if @error=0 ; YES
$disp=$disp+1 ? if $disp<10 " " endif
"$disp - "
$programs[$disp]=$program ; store its name for later
readvalue("$base\$program", "DisplayName") ; and display the Full name
endif

; this restores @error to 0 so that a failure to find the UninstallString
; value does not prematurely end the EnumKey loop
$=enumkey($base, $indexQ)
loop

? ? "Enter the number of the program you wish to Uninstall or Q to Quit : "
gets $which
if $which="Q" ? ? "That was close..." ? exit endif
? ?
$choice=$programs[$which]
"You chose : " readvalue("$base\$choice", "DisplayName")
if @error<>0 "$choice" endif

? ? "Are you sure ?"
get $yn
if $yn="n" ? ? "That was close..." ? exit endif

Toast app
$runstring=readvalue("$base\$choice", $quiet)
if @error<>0 $runstring=readvalue("$base\$choice", $loud) endif

;? ? "Running: $runstring" ? ; Uncomment this line and comment the next one
shell "%comspec% /c $runstring" ; if you want to see what would happen without it happening...

? ? "All done, thanks" ?

Here's a sample of the remove directory script..

code:
 

;Uninstall Winamp
$LongKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\winamp\"
$exist = existkey($Longkey)
if $exist = 0
" Winamp Found.. Removing..."
$UninstallStr = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\winamp","UninstallString")
SHELL $UninstallStr + " -A"
"Complete." ?
else
" Winamp Not installed." ?
endif

;Remove Winamp Directory
IF (EXIST ("C:\Program Files\winamp") = "1")
" Winamp Folder Found...Removing..."
cd "C:\Program Files\winamp"
del "*.*"
cd ".."
rd "winamp"
"Done." ?
endif



Let me know if you need any more help.

[Smile]
_________________________
Who are you? Who slips into my robot body and whispers to my ghost?

Top
#21016 - 2002-05-06 03:20 AM Re: Roaming Profile Cleanup
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
Wow, that's an oldie - 24 nov 2000. Where did you find it?

cj

Top
#21017 - 2002-05-07 09:40 AM Re: Roaming Profile Cleanup
Ghost Offline
Starting to like KiXtart

Registered: 2000-09-14
Posts: 171
I got it when it was first posted.

A BIG thanks to you CJ, the Kix King.

[Smile]
_________________________
Who are you? Who slips into my robot body and whispers to my ghost?

Top
#21018 - 2002-05-07 10:06 PM Re: Roaming Profile Cleanup
a_non_moose Offline
Fresh Scripter

Registered: 2002-05-03
Posts: 17
Loc: UGA
I've found this to be invaluable:
save to a .reg file, in plain text format:

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"ExcludeProfileDirs"="Cookies;History;Temporary Internet Files;Temp;Recent"

Everything in the %windir% and subdirs is ignored during logoff.
Everything else is synced normally.

Moose

Top
#21019 - 2002-05-08 09:25 AM Re: Roaming Profile Cleanup
Ghost Offline
Starting to like KiXtart

Registered: 2000-09-14
Posts: 171
But, carn't you set that in Poledit?

[Smile]
_________________________
Who are you? Who slips into my robot body and whispers to my ghost?

Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 363 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.031 seconds in which 0.011 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