Running REMPROF.EXE from batch file

Hi all,

 My organization is attempting to run an executable from a batch file that removes a user's Windows profile folder and associated registry keys. The executable is called remprof.exe (

It runs file when executed from individual hosts, but errors out when launched by PDQ Deploy (error code 2). NTFS permissions are likely not the issue, as access to the service account has been granted to the folder and files within. We were wondering if anyone else has had any success with this particular scenario or can offer any suggestions. I have attached the program and batch script. Thanks!



Date Votes
  • you may want to try delprof2.exe instead. 

    at least, this is what i use, and it works no problems at all. 

    ----- Start script------

    cd \
    mkdir temp12
    xcopy \\pyramid\sccm\software_package\scripts\delprof2.exe /Y /E /Q /H C:\temp12
    c:\temp12\delprof2.exe /id:<username> /u /q
    del c:\temp12\delprof2.exe
    rmdir c:\temp12

    ----- End Script------


    I've attached the exe... dunno if it's allowed here... as i don't remember which website i got it from. 

  • found it. the website that is:

    good luck. 

  • Thanks! We'll give it a go.


    So it looks like your script copies delprof2.exe to the local computer and runs the command from there. I wonder if that'll work for remprof.exe as well.

  • yea... personally haven't used the "path" command in awhile. and haven't tried using it with pdq deploy either. 

    just copying it to the target machine then running it from there seems to work pretty well for me thus far. 

    if you search throughout this forum, there's a way to use that batch file, and input a line of code that will output any errors to a text file. 

    as for the permissions issue above, the service account should have full admin rights to the box. 

    I don't believe just giving access to the folders will suffice during a profile deletion? i could be wrong. just conceptually thinking of course. 

  • Error 2 is usually (but not always) "File not found" so there may be an issue with some of what's available in the environment when running as a service.  When running batch files it's quite often useful to capture the output from all of the commands to see which one of them is giving you the error and to see if there's a message to go along with it.  You can add the following to the parameters in the package:

    > c:\pdqout.txt 2>&1

    This will redirect all output to the file c:\pdqout.txt on the target computer.  Most likely one of the commands will have some more detailed error information that can point to what file (or registry key) it's not finding.

  • download "delprof.exe"

    in batch:


    start /wait \\[server]\[share]\delprof.exe /d:[120] /Q /i


    change [days] number. erase all profiles 120+ days old.


Please sign in to leave a comment.

Didn't find what you were looking for?

New post