I need to create post build event to perform the following:
sn -i MyKey.pfx MyKeyContainerName
tlbimp $(ConfigurationName)\\MyCom.tlb /out:$(ConfigurationNam
I've been researching this for almost two days now. I tried older versions of sn.exe (going back as far as 2.0!), but I couldn't get the echo PASSWORD |
trick to work.
In the end, I did this:
[void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
Start-Process "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe " -ArgumentList "-i
`"Certificate.pfx`" VS_KEY_XXXXXXX" -NoNewWindow -Wait
[System.Windows.Forms.SendKeys]::SendWait("PASSWORDHERE~")
SendWait()
sends keys to the current activated window. Since we're starting sn.exe
using Start-Process
with the -NoNewWindow
modifier, our window is already focussed.~
is a special character, representing the ENTER button. {ENTER}
is also possible, but that's for the Enter button near the numpad on your keyboard. Probably doesn't make any difference, but I just wanted to be sure.Source I used: https://technet.microsoft.com/en-us/library/ff731008.aspx
I didn't need Visual Basic's AppActivate()
in the end because of -NoNewWindow
.
Update: Works even better with -Wait
argument!