forked from Synergex/CodeGen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignFile.bat
More file actions
56 lines (41 loc) · 1.21 KB
/
Copy pathSignFile.bat
File metadata and controls
56 lines (41 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@echo off
setlocal
pushd %~dp0
if "%1"=="" goto usage
set FILE_TO_SIGN=%1
if not exist "%FILE_TO_SIGN%" (
echo ERROR: File %FILE_TO_SIGN% was not found!
goto done
)
if not defined CODE_SIGN_CERT (
echo ERROR: No code signing certificate is defined. Set environment varaible CODE_SIGN_CERT.
goto done
)
if not exist "%CODE_SIGN_CERT%" (
echo ERROR: Code signing certificate %CODE_SIGN_CERT% was not found!
goto done
)
set PASSWORD=%2
if not "%PASSWORD%"=="" goto gotPassword
set PASSWORD=%CODE_SIGN_PWD%
if "%PASSWORD%"=="" (
echo ERROR: Code signing password is not defined. Set environment variable CODE_SIGN_PWD.
goto done
)
:gotPassword
set TIMESTAMP_URL=http://timestamp.entrust.net/TSS/AuthenticodeTS
echo.
for %%F in ("%FILE_TO_SIGN%") do echo Signing %%~nxF
rem Should be able to use %WindowsSdkDir% but it looks like Visual Studio clears it for some reason!
"C:\Program Files (x86)\Windows Kits\10\bin\x86\signtool.exe" sign /f "%CODE_SIGN_CERT%" /p %PASSWORD% /t %TIMESTAMP_URL% /fd SHA256 /q "%FILE_TO_SIGN%"
if "%ERRORLEVEL%"=="0" (
echo SUCCESS!
)
goto done
:usage
echo.
echo Usage: SignFile file [password]
echo.
:done
popd
endlocal