5 echo cert setup starting
8 call :setscriptvariables %1
9 IF NOT DEFINED SUPPORTED_MODE call :displayusage
10 IF DEFINED SETUP_SERVICE call :setupservice
15 set PFX_FILE=identity.pfx
19 set SERIAL=30 3e 60 f8 cb 96 95 81 48 33 6f da f2 09 0b b7
21 REM Determine which certificates are installed on the machine.
22 for /f "delims=" %%l in ('certmgr.exe -all -s -r LocalMachine My') do (
24 if /i "%%l" == " %SERIAL%" (
30 if %LocalMachine_My% == 1 (
34 REM If this is Windows XP show help text indicating the certificate needs to be imported manually.
36 (ver | findstr /C:"5.1") && set XP=1
38 goto displaywinxpusage
41 REM Import server certificates on Windows 2003 - certutil is only on Windows 2003
42 if NOT %LocalMachine_My% == 1 (
44 echo Server cert setup starting
45 echo Installing %SERVER_NAME% certificate into the LocalMachine/My store
47 echo Importing %PFX_FILE% to LocalMachine/My store ...
49 certutil -importpfx -p %PFX_PASSWORD% %PFX_FILE%
54 IF DEFINED EXPORT_SERVICE GOTO exportservice
57 echo copying server cert to client's CurrentUser store
59 certmgr.exe -add -r LocalMachine -s My -c -n %SERVER_NAME% -r CurrentUser -s TrustedPeople
63 (ver | findstr /C:"5.1") && set XP=1
68 REM Show instructions for adding server certificates
71 echo ********************************
72 echo MANUAL SET UP INSTRUCTIONS:
73 echo ********************************
74 echo Use the MMC Console Certificates Snap-in to install the
75 echo required server certificates into the
76 echo LocalMachine/My ^(Personal^) certificate store.
78 echo The password for the PFX files is "%PFX_PASSWORD%".
80 echo Then run this script again copy the server certificate
81 echo to the currentuser trusted people store.
84 echo See this sample's ReadMe topic in the documentation for detailed instructions.
90 REM cleans up certs from previous runs.
95 echo -------------------------
97 echo -------------------------
98 certmgr.exe -del -r CurrentUser -s TrustedPeople -c -n localhost
99 certmgr.exe -del -r CurrentUser -s TrustedPeople -c -n %SERVER_NAME%
101 echo -------------------------
102 echo del service certs
103 echo -------------------------
104 certmgr.exe -del -r LocalMachine -s My -c -n localhost
105 certmgr.exe -del -r LocalMachine -s My -c -n %SERVER_NAME%
108 echo *****************
109 echo Cleanup completed
110 echo *****************
116 echo exporting service cert to service.cer
118 certmgr.exe -put -r LocalMachine -s My -c -n identity.com service.cer
122 REM Parses the input to determine if we are setting this up for a single machine, client, or server
123 REM sets the appropriate name variables
124 IF [%1]==[] CALL :singlemachine
125 IF [%1]==[service] CALL :service
129 REM cleans up certs from previous runs.
130 echo ****************
131 echo Cleanup starting
132 echo ****************
134 echo -------------------------
135 echo del client certs
136 echo -------------------------
137 certmgr.exe -del -r CurrentUser -s TrustedPeople -c -n localhost
138 certmgr.exe -del -r CurrentUser -s TrustedPeople -c -n %SERVER_NAME%
140 echo -------------------------
141 echo del service certs
142 echo -------------------------
143 certmgr.exe -del -r LocalMachine -s My -c -n localhost
144 certmgr.exe -del -r LocalMachine -s My -c -n %SERVER_NAME%
147 echo *****************
148 echo Cleanup completed
149 echo *****************
155 echo Running setup script for Single Machine
159 SET SERVER_NAME=identity.com
164 echo Running setup script for Service
169 SET SERVER_NAME=identity.com
174 ECHO Single Machine - Setup.bat
175 ECHO Service Machine - Setup.bat service