Home > Batch Scripting, Citrix, Microsoft, Remote Desktop Services (RDS), Scripting, Server Based Computing, XenApp > 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!!!

  2. Gibbon
    July 21, 2010 at 4:47 am | #2

    Doesnt work, I get:
    PsExec could not start remprof.exe on Server01:
    The parameter is incorrect.

    Any ideas?

  3. July 21, 2010 at 8:06 am | #3

    Hi Gibbon,

    It’s been a long time since i used this script, so i downloaded it again.

    It seems to work ok for me, the parameter incorrect error would suggest to me that the username has a space in it (if this is the case wrap the name in quotes e.g. “user name”)

    Failing that feel free to email me a screenshot of the error to andrew.morgan@o2.ie and i’ll take a look.

  4. May 25, 2011 at 11:05 pm | #4

    Just a quick update a new version of REMPROF is available for Windows 7, vista, and Windows 2008 environments. Download it at http://www.ctrl-alt-del.com.au/CAD_TSUtils.htm. Thanks for the support Andrew. Your script is brilliant!!

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 467 other followers