How to sign EXE files with an authentication certificate VB.NET

Useful Microsoft Visual Studio code snippets. Dot Net, VB, ASP, ASPX.
Post Reply
Z12
Site Admin
Posts: 20
Joined: Thu Sep 30 2021, 11:47
Location: UK
Contact:

How to sign EXE files with an authentication certificate VB.NET

Post by Z12 »

To sign your EXE in Microsoft Visual Studio Professional 2019.

Save you certificate file (E.G. MyCertificate.pfx) to a network location (E.G. \\MyServer\MyShare$\MyCertificates\). This can be a local folder.

Find the location of signtool.exe on your PC.

Substitute the path to your signtool.exe in the following code.
Substitute the path to your certificate file and the name of your certificate file in the following code.
Substitute MyPassword in the following code with the password for your certificate file.

Code: Select all

"C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool.exe" sign /f "\\MyServer\MyShare$\MyCertificates\MyCertificate.pfx" /p MyPassword /v "$(TargetPath)"
The go to:
Project / Project Properties /Compile / Build Events / Edit Post-build
And add your modified code to the "Post-build event command line".

Re build your EXE and now it will be signed using your certificate file.
If you find Z12 Web Tools useful and would like to show your appreciation...
Why not Buy Me A Coffee to say: Thank You!


Post Reply