P
proWare Solutions GmbH
Guest
Hi!
I am trying to sign a VB-Script file in a C# application by invoking the Set-ExecutionPolicy commandlet.
The code is:
StringBuilder sb = new StringBuilder();
sb.AppendLine($"$cert = Get-ChildItem -path cert:{thumbprint} -recurse");
sb.AppendLine("foreach ($c in $cert) {if ($c.hasPrivateKey -eq $true) {break}}");
sb.AppendLine("if ($c.hasPrivateKey -eq $true) {Set-AuthenticodeSignature \"" + filePath + "\" -Certificate $c }");
pipeline.Commands.AddScript(sb.ToString());
System.Collections.ObjectModel.Collection<PSObject> psResult = pipeline.Invoke();
The code works with ps1 files and executables but not with vb-script-files.
The same code runs, when executed directly in powershell.
Is there a way besides creating the script on the fly, signing it and running the script in a separate process?
Any help is appreciated.
Kind regards
Alex
Continue reading...
I am trying to sign a VB-Script file in a C# application by invoking the Set-ExecutionPolicy commandlet.
The code is:
StringBuilder sb = new StringBuilder();
sb.AppendLine($"$cert = Get-ChildItem -path cert:{thumbprint} -recurse");
sb.AppendLine("foreach ($c in $cert) {if ($c.hasPrivateKey -eq $true) {break}}");
sb.AppendLine("if ($c.hasPrivateKey -eq $true) {Set-AuthenticodeSignature \"" + filePath + "\" -Certificate $c }");
pipeline.Commands.AddScript(sb.ToString());
System.Collections.ObjectModel.Collection<PSObject> psResult = pipeline.Invoke();
The code works with ps1 files and executables but not with vb-script-files.
The same code runs, when executed directly in powershell.
Is there a way besides creating the script on the fly, signing it and running the script in a separate process?
Any help is appreciated.
Kind regards
Alex
Continue reading...