Retroactively Signing Office COM Add-in - plugins

I have a .msi and .exe installer for a COM Office Add-in, but there is no publisher certificate with this installer.
I need to apply a certificate from my own authority to this installer.
How do I do this?

You can use the SignTool.exe (Sign Tool) for signing the installer with your own digital signature. Sign Tool is a command-line tool that digitally signs files, verifies signatures in files, and time-stamps files. This tool is automatically installed with Visual Studio. To run the tool, use the Developer Command Prompt for Visual Studio (or the Visual Studio Command Prompt in Windows 7). For example:
The following command digitally signs a file by using a certificate stored in a password-protected PFX file.
signtool sign /f MyCert.pfx /p MyPassword /fd SHA256 MyFile.exe
The following command digitally signs and time-stamps a file. The certificate used to sign the file is stored in a PFX file.
signtool sign /f MyCert.pfx /t http://timestamp.digicert.com /fd SHA256 MyFile.exe

Related

Start Developer PowerShell for VS 2019 from Azure DevOps pipeline

We have configured a windows virtual machine and deployed an agent there to build our code and run scripts.
In our VM we two different flavors of PowerShell command prompt:
Windows PowerShell
Developer PowerShell for VS 2019.
How can we start "Developer PowerShell for VS 2019" from our pipeline YAML script and execute our checked out .ps1 file there?
There are several flavors of PowerShell tasks that can be initiated from the pipeline though and not sure which one of them will serve the purpose. They are the following:
Azure PowerShell
PowerShell
PowerShell on Target Machine
Service Fabric PowerShell.
Which of the above represent "Developer PowerShell for VS 2019"?
The reason behind this specific flavor of PowerShell is:
Need to have some of the .NET Framework Tools (CorFlags.exe) which are only accessible in the "Developer PowerShell for VS 2019" and not in the other one.
The Developer PowerShell for VS 2019 is a regular PowerShell with a module imported, you can see exactly what in this way:
Go the Start menu and search for Developer PowerShell for VS 2019.
Right-click on it and Open file location - you will get this:
Now right-click again on the Developer PowerShell for VS 2019 shortcut and Properties.
You will see in the location that is run the regular PowerShell with some command:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -noe -c "&{Import-Module """C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"""; Enter-VsDevShell bc97b47b}"
Now, if you open a PowerShell and run the script there:
&{Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"; Enter-VsDevShell bc97b47b}
You will get the Developer PowerShell for VS 2019 and CoreFlags.exe will work:
So, you need to use the regular PowerShell task (your option 2) and run the above command at the begging of the script.
Note: you should copy exactly the command you see in the Properties, in each machine it could be different.

How to Connect to Azure from Visual Studio Code Terminal

I have installed the required software and Azure PowerShell cmdlets on local system. I tried to execute a powershell script by connecting to Azure from Visual Studio Code Terminal. Below is the error.
Import-Module Microsoft.Online.SharePoint.PowerShell
function PublishToAzure{
Add-AzureAccount
......
......
}
Error is..
Add-AzureAccount : The handle is invalid
Visual Studio Code Settings:
// Place your settings in this file to overwrite the default settings
{
"terminal.integrated.shell.windows": "C:\\WINDOWS\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
}
Console of Windows Azure Active Directory Module for Windows PowerShell Properties
Target is:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "Import-Module MSOnline"
System Properties: 64bit Win7 OS
You may connect and manage Azure resources from within VS Code's terminal window by installing Microsoft Azure CLI 2.0. (https://aka.ms/InstallAzureCliWindows).
After CLI 2.0 is successfully installed in your environment, add the CLI 2.0 components to your environment path.
For example, my environment is Windows 10 and VS Code v1.13.0. I successfully ran the CLI 2.0 MSI installer for Windows. In my VS Code terminal session, I add the path to my PowerShell environment via this command:
$Env:Path += ';C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin'
To work within my Azure subscription(s), first I login via the command
az login
Follow the prompts to browse to a URL to complete the login to your Azure account and authorize the CLI session. Additional help on CLI 2.0 commands may be found at this link, https://aka.ms/cli
I know this thread is old and my answer a bit late but I hope this helps someone.
Cheers,
CarnegieJ

powershell tf command not recognized as the name of a cmlet

tf : The term 'tf' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and
try again.
I set up the environment variable but does not work. tf command works in Developer Command Prompt for VS2013 but does not work in Powershell. How can I make this to work?
You need to include tf.exe full path. For example, you want to check in files with tf checkin command in PowerShell:
$filePath = "C:\Users\username\Source\Workspaces\teamproject\solutionname\projectname\Class1.cs"
Set-Alias tfs "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\tf.exe"
tfs checkin $filePath /noprompt
This worked for me. I added the path of TF.exe
("C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE" in my case) to system environment PATH variable (through My Computer->Properties->Advanced System Settings->Environment Variables->System Variables->Path->Edit).
You can check if "tf" is working by typing "tf" in the powershell. If you get an output something as :
Microsoft (R) TF - Team Foundation Version Control Tool, Version 14.102.25619.0
Copyright (c) Microsoft Corporation. All rights reserved.
......
tf is working properly.
To answer the question form another perspective, this is how you are supposed to call the tf environment variable you created:
%tf%
I've given it the value C:\Windows\notepad.exe, and the application opens when calling the variable from cmd.
You need to download and install the Microsoft Team Foundation Server Power Tools in order to run the TFPT command.
TFS 2015 version can be found here:
Microsoft Team Foundation Server 2015 Power Tools
If you run the Powershell from VS Tools then you need to close your Powershell session and restart your VS in order for it to pick up the newly installed tools and run the Powershell again.

Enabling app sideloading using NSIS on Windows10

I have a Windows Universal App that needs to be sideloaded. I am using NSIS with a powershell script to install it. I would like to have the NSIS installer enable app sideloading in the Windows settings. I have already looked at the documentation from Microsoft about enabling app sideloading (https://msdn.microsoft.com/library/windows/apps/xaml/dn706236.aspx).
If I run the powershell command from the documentation to set the registry in a standalone powershell window it works fine and I can install the app. However, when I put the registry command inside the installer it doesn't work. I have tried using both Powershell and NSIS to set the registry. Using the WriteRegDWORD command from NSIS and the reg add command from Powershell both say that they succeeded. Reading back the values produces the correct value. If I try to set the registry using Set-ItemProperty in the Powershell script it complains that the path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock doesn't exist.
There doesn't seem to be any way to tell whether sideloading is enabled or not from Powershell. Even outside of the installer context checking the registry is not a valid solution because enabling sideloading via Windows Settings doesn't set the registry.
So my current solution is to try to install the app. If the install fails, check the error message and see if it's complaining about sideloading not being enabled. If that is the case then open up Windows Settings to the developer features page and pop up a message saying that sideloading needs to be enabled in order to continue. Then after Windows Settings is closed reattempt to install the app.
Is it possible to enable sideloading from an NSIS installer? Or is it possible to do a check to see if sideloading is enabled or not?
64-bit versions of Windows have a 64-bit and a 32-bit "version" of the registry, this means that what you see in Regedit might not be the same as what a 32-bit application sees.
Use the SetRegView instruction to change the view used by the installer.
Process Monitor is a useful tool to debug registry issues like this...

cURL command failure

I am attempting to use curl commands in a batch file I am writing. I have downloaded the latest curl executable and run it but I cannot use the command "curl" What steps should I take to use it correctly? The Command line still says
"curl is not recognized as an internal or external command, able program or batch file"
I am not interested in doing anything else with cURL
You will have to add the directory containing curl.exe to your path, probably the bin directory.
In Windows XP you can do this by:
Right click your computer and choose properties
Click the advanced tab
Click environmental variables
Find path in the list and add the path to your curl directory
Steps to install curl in windows
Install cURL on Windows
There are 4 steps to follow to get cURL installed on Windows.
Step 1 and Step 2 is to install SSL library.
Step 3 is to install cURL.
Step 4 is to install a recent certificate
Step One: Install Visual C++ 2008 Redistributables
Download Visual C++ 2008 Redistributables.
Step Two: Install Win(32/64) OpenSSL v1.0.0k Light
Also from http://www.shininglightpro.com/products/Win32OpenSSL.html
For 64bit systems
Win64 OpenSSL v1.0.0k Light
For 32bit systems
Win32 OpenSSL v1.0.0k Light
Step Three: Install cURL
Depending on if your system is 32 or 64 bit, download the corresponding** curl.exe.**
For example, go to the Win64 - Generic section and download the Win64 binary with SSL support (the one where SSL is not crossed out).
Visit http://curl.haxx.se/download.html
More specific Link: http://curl.haxx.se/latest.cgi?curl=win64-ssl-sspi
Copy curl.exe to C:\Windows\System32
Step Four: Install Recent Certificates
Do not skip this step.
Download a recent copy of valid CERT files from http://curl.haxx.se/ca/cacert.pem
Copy it to the same folder as you placed curl.exe (C:\Windows\System32) and rename it as curl-ca-bundle.crt
If you have already installed curl or after doing the above steps, add the directory where it's installed to the windows path:
1 - From the Desktop, right-click My Computer and click Properties.
2 - Click Advanced System Settings .
3 - In the System Properties window click the Environment Variables button.
4 - Select Path and click Edit.
5 - Append ;c:\path to curl directory at the end.
5 - Click OK.
6 - Close and re-open the command prompt
Looks like its not on your path - try opening a new console window.
You need to add it to the path environment variable. If you want to do it through batch then you can update the reg key it stores the directories in with curl.exe like this:
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /d "curlpath\curl.exe";%path%" /f
Or if the exe isn't dependent on any other files you could copy it to of paths existing directories like C:\Windows\system32.
Hope this helps!