0

I've been trying to figure this out for a while. I've searched online and the solutions I've tried don't seem to work.

This runs ok from my PC:

Dim sourceName As String = File_To_Encrypt
Dim gpgsourceName As String = File_To_Encrypt & ".gpg"
Dim argumentString As String = " --batch --yes --recipient recname --encrypt " & sourceName
Dim gpgcmd As String = "\\serv2014\c$\Program Files (x86)\GnuPG\bin\gpg.exe"
Process.Start(gpgcmd, argumentString)

When I try to run in production it does not work. I'm a newbie to VB I've tried any number of combos :

"""\\serv2014\c$\Program Files (x86)\GnuPG\bin\gpg.exe"""""
ControlChars.Quote & "\\serv2014\c$\Program Files (x86)\GnuPG\bin\gpg.exe" & ControlChars.Quote

Even this I saw from searching: "c:\sp` ace\test.ps1" << did not work

"\\serv2014\c$\Program` Files` (x86)\GnuPG\bin\gpg.exe"

I read this: Note: In VB.NET, the escape character of " is "". With three quotes it just seemed to hang the process:

 """\\serv2014\c$\Program Files (x86)\GnuPG\bin\gpg.exe"""

Tried this too: error message is system cannot find file specified

"\\serv2014\c$\Program Files (x86)\GnuPG\bin\gpg.exe"""

Appreciate any suggestions.

I can run it fine on my PC, the Windows admin told me if the path had a space in it then I had to quote it properly.

I can execute the command from the cmd line of my PC - no problem.

I can run the vb program from the button of my Visual Studio - runs ok. I can run the command like this from the cmd line on my PC:

C:\WINDOWS\system32>"\\serv2014\c$\Program Files (x86)\GnuPG\bin\gpg.exe" --batch --yes --recipient recpname --encrypt \\serv2014\e$\Extracts\filename.csv

When I build the .exe put it on the server and run it from the scheduler - it doesn't work. I asked the Windows admin if it was a permissions thing - he said no. I'm new to this Windows VB stuff, so not sure what else to check.

I mentioned what the results where it either hangs - job gets to this step and hangs does not exit I have to kill the process. Or as mentioned there is a message in the error log "system cannot find file specified"

bop-a-nator
  • 111
  • 1
  • 11
  • “Does not work” how exactly? Are you sure the issue is quoting and not something else? – Igor Skochinsky Aug 23 '18 at 22:35
  • I added details above – bop-a-nator Aug 23 '18 at 23:07
  • You shouldn't need any quotes there (in both `VB.Net` and `C#` that string is a valid path in this context). Are you sure you app doesn't need admin privileges or there's a "special" group policy setup for this, so that anyone can reach that admin share from everywhere? Have you tried using the IP address instead of the machine name? – Jimi Aug 23 '18 at 23:25

1 Answers1

-1

Please ask Admin to put gpg.exe into PATH environment variable, you can avoid these long file paths. There by, if you need to scale to many systems it's already part of each system as a pre-requisite.

  • Change the backtick to a backward slash say from "\\serv2014\c$\Program` Files` (x86)\GnuPG\bin\gpg.exe" to "\\serv2014\c$\Program\ Files\ (x86)\GnuPG\bin\gpg.exe" – Sai Prasad M Aug 23 '18 at 23:27
  • `Program Files (x86)` is the name of the directory not 3 separate directories. – Mary Aug 24 '18 at 03:19