Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch file assistance

Status
Not open for further replies.

aledid

IS-IT--Management
Sep 16, 2002
22
US
Hi,

I have written the batch file below to deleted system certificates. It works great if you want it to only run while logged in as the current profile.

I want it to delete the certificates for all the profiles on the computer. Can anyone assist me?

Batch file
##################

@echo off

echo Deleting wireless certificates - Please wait.
echo.
pause
c:
cd ""%userprofile%\Application Data\Microsoft\SystemCertificates\My\Certificates\"
attrib -s -h -r *.*
del /q *.*

echo Please shutdown and restart your computer!!!!

@echo off
pause
 
The %userprofile% parameter will only map to the user running the batch. Use something like this instead:

##################

@echo off

echo Deleting wireless certificates - Please wait.
echo.
pause

FOR /f %%j in ('dir c:\users /ad /b') DO attrib -s -h -r c:\"Documents and Settings\%%j\Application Data\Microsoft\SystemCertificates\My\Certificates\*.*"&& del /q c:\"Documents and Settings\%%j\Application Data\Microsoft\SystemCertificates\My\Certificates\*.*

echo Please shutdown and restart your computer!!!!

@echo off
pause


-Joe
 
Dang-it, I need to learn to proof read better. Within the parenthesis in the FOR line, change c:\users to "c:\Documents and Settings".

I am on Vista and had to change the script when I posted it to match XP. You could also use some logic in the beginning of your script to determine if you are using XP or Vista and then run the proper command. Of course, if all you are using is XP, you don't need to do this.

Sorry......

-Joe
 
The person running the batch would have to be an admin for this to work because they would need to modify all other profiles on the computer.
 
chipk - You are correct, the user running this batch would have to be an admin but that is not outside of the requestor's requirements. The original issue was that the original script would only delete the current users certificates and there was a need to delete all certificates for all users. This can only be done with an admin account or by granting a special user full-control rights on the "Documents and Settings" directory.



-Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top