Search code examples
vbams-accessshellexecutewsh

Access hangs on WScript.Shell.run


I am using WScript.Shell to run a third party executable that reads a file and sends some data.

Dim objShell As Object, Shellerror As Long
Set objShell = CreateObject("WScript.Shell")

The problem is, that Access hangs on the .run statement.

Shellerror = objShell.Run(Chr(34) & PreveriPath(ApplicationPath) & "SimplyTax\simplytax.exe" & Chr(34) & "" & VrstaZahteve & " " & Delovanje & " " & SWid & " " & Chr(34) & Datoteka & Chr(34) & " " & Geslo & " RD#" & Chr(34) & ResponseDatoteka & Chr(34), 0, True)

You probably cant see anything with just this call, here is the string that actually gets run.

Shellerror = objShell.Run("F:\AA\Bicom 5\SimplyTax\simplytax.exe" racun test 10456317 "F:\AA\Bicom 5\SimplyTax\racun.txt" test RD#"F:\AA\Bicom 5\SimplyTax\Response\STResponse.txt", 0, True)

Now the problem here is, that execution just hangs on this line, without any errors or anything until I forcefully close Access (it goes into a not responding state).

I have been researching this problem for two days now and the only thing I could figure out is that it only hangs when you have blanks in the file paths. I cant just remove the blanks from the paths, because we are doing this for a few different companies, that have different folder structures (some have with spaces, some without).

As far as I can see, the companies, that use paths without spaces don't have any problems.

I have tried a few things with the paths, none of them seem to work. I put double quotes around them, I put single quotes around them, I removed all the quotes, I tried using the ShellExecute function which produced the same results, it just made Access not respond faster.

I feel like I'm hitting a wall here... What am I doing wrong?


Solution

  • Well sadly i had no luck in finding a solution to this problem. It appears like the program in question just can't handle file paths with spaces...

    I simply added a new field in my application, that expects a file path without spaces and told them to copy the program to that path. Now it works without a problem.

    Thank you for your replies and help.