0

VB.NET Process Code I am using to invoke

 Dim p As Process = New Process()
    p.StartInfo.FileName = "PowerShell.exe"
    p.StartInfo.Arguments = "C:\Users\dbashore\Documents\SFTP2.ps1"
    p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
    p.StartInfo.UseShellExecute = False
    p.StartInfo.CreateNoWindow = True
    p.StartInfo.RedirectStandardError = True
    p.Start()
    p.WaitForExit()
    Dim sStdErr_psRename As String = p.StandardError.ReadToEnd()
    Console.WriteLine("Exit code : {0}", p.ExitCode)
    Console.WriteLine("StdErr : {0}", sStdErr_psRename)

Here is the PowerShell Line that is failing

Add-Type -Path "C:\Windows\System32\WinSCPnet.dll"

Error says no such file exists.

When I copy the DLL to Mydocuments and change the path to point there the script runs.

Why can't it use .DLL's directly from system32. I'm sure it related to elevated permisions but i can't find anything about what property needs to be added/changed

The script runs fine from PoweshellISE

Thanks

Dean

  • 1
    The following may be helpful: https://stackoverflow.com/questions/70924974/qwinsta-server-in-vb-net-display-result-in-datagridview/70927338#70927338 – Tu deschizi eu inchid Feb 11 '22 at 20:49
  • For PowerShell, the following may be helpful: https://stackoverflow.com/questions/58211358/how-to-automate-either-powershell-or-powershell-core-for-same-machine/58211901#58211901 and https://stackoverflow.com/questions/70403581/execute-a-continuously-running-powershell-command-and-get-result-into-form – Tu deschizi eu inchid Feb 11 '22 at 21:25
  • 1
    If file `C:\Windows\System32\WinSCPnet.dll` really exists, the problem is likely related to running in a 32-bit process on a 64-bit system (or the file only existing in the 32-bit-specific dir. and a 64-bit process therefore not seeing it); the post linked to in the first comment provides clues. – mklement0 Feb 11 '22 at 22:51

0 Answers0