Home > Administration, Citrix, Tools > Deleting a user profile from multiple servers:

Deleting a user profile from multiple servers:

Ever needed to delete a users profile from 50+ servers? Ouch yes it happens, yes its annoying and yes it time consuming. I had a requirement to do this recently and i had to script it to save me logging into all 40+ Citrix servers and deleting the profile manually.

Now microsoft do have a tool called delprof and it is quite handy… but if you only want to delete one profile (not a whole rake of them) you are in trouble.

Step in the genius’s in ctrl alt del consultancy with remprof.exe. I’ve touched on this tool before, but today I’ve packaged a one stop batch file to delete a certain users profile from as many servers as you like!

The file relies on psexec, remprof and a text file containing the server names. if you are going to launch this from the network ensure you have the drive mapped. As with all my scripts it’s un-intrusive and wont leave you needing a restart.

The code can be found after the jump, if you dont care, you can find the script here:

@echo off
::Andrew Morgan 22/05/08
::Delete a users profile from a citrix server
::Relies on remprof.exe and servers.txt being in the installation folder
::servers.txt must have one servername per line and script must be as an administrative account.
@echo Kicking off script:
@echo.
::checking for servers list
ECHO Checking for servers list: & IF EXIST servers.txt (@echo Success & goto RemCheck) ELSE (@Echo Failure & goto txt-missing)

:RemCheck
::Checking for remprof.exe file
@echo.
ECHO Checking for Remprof.exe: & IF EXIST remprof.exe (@echo Success & goto psexeccheck) ELSE (@Echo Failure & goto rem-missing)

:psexeccheck
::Checking for psexec.exe file
@echo.
ECHO Checking for psexec.exe: & IF EXIST psexec.exe (@echo Success & goto set) ELSE (@Echo Failure & goto psexec-missing)

:set
::Setting username
@echo.
@echo please enter the nt login of the profile you wish to delete: & set /p user=
@echo.
@echo Deleting profile for %userdomain%\%user% from the specified servers.
goto install
exit

:install
psexec -accepteula @servers.txt -c remprof.exe %user%
@echo Command Completed, check above for results.
pause
exit

:rem-missing
@echo Error! Remprof.exe is missing from installation folder
@echo.
@echo. Check the script folder of this batch file for remprof.exe, if its not there, put it there, if it is there… panic.
pause
exit

:txt-missing
@echo servers.txt missing from installation folder
@echo.
@echo. Check the script folder of this batch file for servers.txt, if its not there, put it there, if it is there… panic.
pause
exit

:psexec-missing
@echo psexec.exe missing from installation folder
@echo.
@echo. Check the script folder of this batch file for psexec.exe, if its not there, put it there, if it is there… panic.
pause
exit

  1. brad
    March 23, 2009 at 7:38 pm | #1

    Excellent! Thank you for putting out this script. Saved lot of time!!!

  1. August 26, 2008 at 1:08 pm | #1