0

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?

rook
  • 5,880
  • 4
  • 39
  • 51
Miha
  • 13
  • 3
  • You have the last parameter `bWaitOnReturn` of `Shell.Run` set to `True`. Is this intentional? If yes, is it necessary? Access doesn't hang, it waits for the called program to finish. [Shell.Run](https://msdn.microsoft.com/en-us/library/d5fk67ky%28v=vs.84%29.aspx) doc. – Andre Dec 10 '15 at 13:00
  • Sadly bWaitOnReturn is needed. I am calling a program, that writes me a .txt file which i then read. I read it right after calling the program, so the waitOnReturn was intentional yes. – Miha Dec 10 '15 at 14:02
  • Ok. Did you check e.g. with Process Explorer, that the called program `simplytax.exe` actually finishes? – Andre Dec 10 '15 at 14:12
  • No, it stays in the processes tab. And I have thought, that the fault could actually be in the program simplytax, but it's weird that it works fine if I don't have any blanks in my file paths (I already sent a mail to the developers of that program, but am still waiting for a response). – Miha Dec 10 '15 at 14:16

2 Answers2

0

Well then that's your solution.

If the called program doesn't finish, Access (or rather Shell.Run) will wait for it. And wait.

You could try passing 1 instead of 0 for intWindowStyle to show the program window. Perhaps it shows an error.

Also this part of your command line looks weird:

test RD#"F:\AA\Bicom 5\SimplyTax\Response\STResponse.txt"

Is RD# really supposed to look like this?

Andre
  • 26,751
  • 7
  • 36
  • 80
  • Ah yes, that RD# is an optional parameter for the program. It's supposed to be that way yes. – Miha Dec 10 '15 at 14:43
0

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.

Miha
  • 13
  • 3