Use the "vs2013 developer command prompt" to run the signature tool. Go to the file directory to be signed and run the command:
Signtool sign/A indicates the program .exe
Signtool-related commands
'''Csharpusage: signtool[Options]
Valid commands: sign -- Sign files using an embedded signature. timestamp -- Timestamp previously-signed files. verify -- Verify embedded or catalog signatures. catdb -- Modify a catalog database. remove -- Reduce the size of an embedded signed file.
For help on a specific command, enter "signtool/? "'''
Store the signature program in a BAT file. To save trouble, I directly merged the file in "vs2013 developer command prompt". The full text is as follows.
'''Csharp
@ Call: getvscommontoolsdir @ if "% vs120comntools %" = "" Goto ErrorNoVs120comntoolsdir
@ Call "% vs120comntools % vcvarsqueryregistry. Bat" 32bit no64bit
@ If "% vsinstalldir %" = "" Goto ErrorNoVsinstalldir @ if "% frameworkdir32 %" = "" Goto ErrorNoFrameworkdir32 @ if "% frameworkversion32 %" = "" Goto ErrorNoFrameworkver32 @ if "% framework40version %" = "" Goto ErrorNoFramework40version
@ Set frameworkdir = % frameworkdir32 % @ set frameworkversion = % frameworkversion32 %
@ If not "% windowssdkExecutablepathX86 % "=" "(@ set" Path = % windowssdkExecutablepathX86 %; % PATH % ")
@ If not "% windowssdkdir %" = "" (@ set "Path = % windowssdkdir % bin \ x86; % PATH % "@ set" include = % windowssdkdir % include \ shared; % windowssdkdir % include \ Um; % windowssdkdir % include \ winrt; % include % "@ set" Lib = % windowssdkdir % Lib \ winv6.3 \ Um \ x86; % lib % "@ set" libpath = % windowssdkdir % references \ commonconfiguration \ neutral; % extensionsdkdir % \ Microsoft. vclibs \ 12.0 \ references \ commonconfiguration \ neutral; % libpath % ")
@ REM root of Visual Studio ide installed files. @ REM @ set devenvdir = % vsinstalldir % common7 \ ide \
@ REM path @ REM ---- @ if exist "% vsinstalldir % team tools \ Performance Tools" (@ set "Path = % vsinstalldir % team tools \ performance tools; % PATH % ") @ if exist "% ProgramFiles % \ HTML Help Workshop" set Path = % ProgramFiles % \ HTML Help Workshop; % PATH % @ if exist "% ProgramFiles (x86) % \ HTML Help Workshop "set Path = % ProgramFiles (x86) % \ HTML Help Workshop; % PATH % @ if exist" % vcinstalldir % vcpackages "set Path = % vcinstalldir % vcpackages; % PATH %
@ If exist "% frameworkdir % framework40version %" set Path = % frameworkdir % framework40version %; % PATH % @ if exist "% frameworkdir % frameworkversion %" set Path = % frameworkdir % frameworkversion %; % PATH % @ if exist "% vsinstalldir % common7 \ tools" set Path = % vsinstalldir % common7 \ tools; % PATH % @ if exist "% vcinstalldir % bin" set Path = % vcinstalldir % bin; % PATH % @ set Path = % devenvdir %; % PATH %
@ REM add path to msbuild binaries @ if exist "% ProgramFiles % \ msbuild \ 12.0 \ bin" set Path = % ProgramFiles % \ msbuild \ 12.0 \ bin; % PATH % @ if exist "% ProgramFiles (x86) % \ msbuild \ 12.0 \ bin" set Path = % ProgramFiles (x86) % \ msbuild \ 12.0 \ bin; % PATH %
@ REM add path to typescript compiler @ if exist "% ProgramFiles % \ microsoft sdks \ typescript \ 1.0" set Path = % ProgramFiles % \ microsoft sdks \ typescript \ 1.0; % PATH % @ if exist "% ProgramFiles (x86) % \ microsoft sdks \ typescript \ 1.0" set Path = % ProgramFiles (x86) % \ microsoft sdks \ typescript \ 1.0; % PATH %
@ If exist "% vsinstalldir % vstsdb \ deploy" (@ set "Path = % vsinstalldir % vstsdb \ deploy; % PATH % ")
@ If not "% fsharpinstalldir %" = "" (@ set "Path = % fsharpinstalldir %; % PATH % ")
@ If exist "% devenvdir % commonextensions \ Microsoft \ testwindow" (@ set "Path = % devenvdir % commonextensions \ Microsoft \ testwindow; % PATH % ")
@ REM include @ REM ------- @ if exist "% vcinstalldir % atlmfc \ include" set include = % vcinstalldir % atlmfc \ include; % include % @ if exist "% vcinstalldir % include" set include = % vcinstalldir % include; % include %
@ REM lib @ REM --- @ if exist "% vcinstalldir % atlmfc \ Lib" set Lib = % vcinstalldir % atlmfc \ Lib; % lib % @ if exist "% vcinstalldir % lib" set Lib = % vcinstalldir % LIB; % lib %
@ REM libpath @ REM ------- @ if exist "% vcinstalldir % atlmfc \ Lib" set libpath = % vcinstalldir % atlmfc \ Lib; % libpath % @ if exist "% vcinstalldir % lib" set libpath = % vcinstalldir % LIB; % libpath % @ if exist "% frameworkdir % framework40version %" set libpath = % frameworkdir % framework40version %; % libpath % @ if exist "% frameworkdir % frameworkversion %" set libpath = % frameworkdir % frameworkversion %; % libpath %
@ REM visualstudioversion @ REM ------------------- @ set visualstudioversion = 12.0
@ Goto end
@ REM coding: getvscommontoolsdir @ set vs120comntools = @ call: getvscommontoolsdirhelper32 HKLM> NUL 2> & 1 @ if errorlevel 1 call: Hangzhou hkcu> NUL 2> & 1 @ if errorlevel 1 call: getvscommontoolsdirhelper64 HKLM> NUL 2> & 1 @ if errorlevel 1 call: getvscommontoolsdirhelper64 hkcu> NUL 2> & 1 @ exit/B 0
: Getvscommontoolsdirhelper32 @ for/F "tokens = 12.0 *" % I in ('reg query "% 1 \ Software \ Microsoft \ visualstudio \ sxs \ vs7"/V "') do (@ if "% I" = "12.0" (@ set "vs120comntools = % K ")) @ if "% vs120comntools %" = "" Exit/B 1 @ set "vs120comntools = % vs120comntools % common7 \ tools \" @ exit/B 0
: Getvscommontoolsdirhelper64 @ for/F "tokens = 12.0 *" % I in ('reg query "% 1 \ Software \ wow6432node \ Microsoft \ visualstudio \ sxs \ vs7"/V" ') do (@ if "% I" = "12.0" (@ set "vs120comntools = % K ")) @ if "% vs120comntools %" = "" Exit/B 1 @ set "vs120comntools = % vs120comntools % common7 \ tools \" @ exit/B 0
@ REM -------------------------------------------------------------------------: ErrorNoVs120comntoolsdir @ echo error: cannot determine the location of the vs Common Tools Folder. @ goto end
: ErrorNoVsinstalldir @ echo error: cannot determine the location of the vs installation. @ goto end
: ErrorNoFrameworkdir32 @ echo error: cannot determine the location of the. NET Framework 32bit installation. @ goto end
: ErrorNoFrameworkver32 @ echo error: cannot determine the version of the. NET Framework 32bit installation. @ goto end
: ErrorNoFramework40version @ echo error: cannot determine the. NET Framework 4.0 version. @ goto end
: End
@ Echo off
Cd % ~ Dp0
Signtool sign/A indicates the program .exe '''