added samples
[windows-sources.git] / sdk / samples / WCFSamples / TechnologySamples / Extensibility / Metadata / CustomMexEndpoint / CS / cleanup.bat
blob395ca2aa8df87ee6e6368d790667f831a660e5f1
1 echo off
2 setlocal
3 set CLIENT_NAME=client.com
4 call :setcomputername
5 ECHO ****************************************************************
6 ECHO WARNING:  This script will not remove service certificates on a 
7 ECHO           client machine from a cross machine run of this
8 ECHO           sample.
10 ECHO If you have run WCF samples that use Certs across machines, 
11 ECHO be sure to clear the service certs that have been installed in
12 ECHO the CurrentUser - TrustedPeople store.
13 ECHO To do this, use the following command:
15 ECHO "certmgr.exe -del -r CurrentUser -s TrustedPeople -c -n <Fully Qualified Server Machine Name>"
17 ECHO For example:
19 ECHO "certmgr.exe -del -r CurrentUser -s TrustedPeople -c -n server1.contoso.com"
20 call :cleancerts
21 DEL client.cer > NUL 2>&1
22 DEL service.cer > NUL 2>&1
23 GOTO end
25 :cleancerts
26 REM cleans up certs from previous runs.
27 echo ****************
28 echo Cleanup starting
29 echo ****************
31 echo -------------------------
32 echo del client certs
33 echo -------------------------
34 certmgr.exe -del -r CurrentUser -s My -c -n %CLIENT_NAME%
35 certmgr.exe -del -r CurrentUser -s TrustedPeople -c -n localhost
37 echo -------------------------
38 echo del service certs
39 echo -------------------------
40 certmgr.exe -del -r LocalMachine -s My -c -n localhost
41 certmgr.exe -del -r LocalMachine -s TrustedPeople -c -n %CLIENT_NAME%
42 certmgr.exe -put -r LocalMachine -s My -c -n %COMPUTER_NAME% computer.cer
43 IF %ERRORLEVEL% EQU 0 (
44    DEL computer.cer
45    echo ****************
46    echo "You have a certificate with a Subject name matching your Machine name."
47    echo "If this certificate is from a cross machine run of WCF samples press any key to delete it."
48    echo "Otherwise press Ctrl + C to abort this script."
49    pause
50    certmgr.exe -del -r LocalMachine -s My -c -n %COMPUTER_NAME%
53 :cleanupcompleted
54 echo *****************
55 echo Cleanup completed
56 echo *****************
58 GOTO :EOF
61 :setcomputername
62 REM Puts the Fully Qualified Name of the Computer into a variable named COMPUTER_NAME
63 for /F "delims=" %%i in ('cscript /nologo GetComputerName.vbs') do set COMPUTER_NAME=%%i
64 GOTO :EOF
66 :end