0

I have two Access databases that I'm opening on the same computer. In one, running this in the immediate window works as expected (opens Notepad):

Shell "notepad.exe"

In the other, I get this error instead:

Run-time error '5': Invalid procedure call or argument

I have not been able to come up with any shell command that will run successfully in that second database. No matter what, I get that error.

What is going on here? Could there be a security setting coming into play? Or perhaps one is an older version?

Edit - More Info

  • When I go to the definition of Shell in the malfunctioning database, it goes to VBA.Interaction.Shell.

  • I get the correct IntelliSense tooltip for Shell.

  • I tried VBA.Shell "notepad.exe" and VBA.Interaction.Shell "notepad.exe" without success (same error).

  • Here are the references that are checked in both databases:

    enter image description here

  • Decompiling did not help.

braX
  • 11,506
  • 5
  • 20
  • 33
MarredCheese
  • 17,541
  • 8
  • 92
  • 91
  • Just two ideas: 1. Is there any code being executed on startup? 2. Take a look in the references of the database. Maybe there is something orphaned? – AHeyne Jun 20 '19 at 04:11
  • 1
    May be there is redefenition of `Shell` function in the second database. Try to press `Ctrl + F2` at 'Shell' in Immediate window to jump to definition. – 4dmonster Jun 20 '19 at 05:19
  • Or be explicit and try `VBA.Shell` which will force the VBA library to be used. –  Jun 20 '19 at 09:16
  • @UnhandledException There's no Autoexec macro defined - if that's what you mean. See my edit regarding the references. – MarredCheese Jun 20 '19 at 15:59
  • @4dmonster When I go to the definition of `Shell` in the malfunctioning database, it goes to `VBA.Interaction.Shell`. – MarredCheese Jun 20 '19 at 16:00
  • @Gareth I tried `VBA.Shell "notepad.exe"` and `VBA.Interaction.Shell "notepad.exe"` without success (same error). – MarredCheese Jun 20 '19 at 16:01
  • You could try a full [Decompile](https://stackoverflow.com/a/3268188/3820271). -- Also, if you type `Shell ` in the faulty db, does it show the correct Intellisense tooltip? – Andre Jun 20 '19 at 16:05
  • @Andre I just tried decompiling per the instructions in that link. I still get the same error afterward. IntelliSense works as expected now and did before as well. – MarredCheese Jun 20 '19 at 16:35

1 Answers1

2

The culprit was our anti-virus software! UGH!

Why did it work in one database and not the other then? I'm told that years ago, anti-virus exceptions were made for my computer for the one database but not the other.

I recommend that any others who encounter this problem check their anti-virus logs/policies. Also, running the database from another computer with different policies in place might shed some light on the issue faster. In this case, when I used remote desktop to log into a server, I was able to call shell successfully.

MarredCheese
  • 17,541
  • 8
  • 92
  • 91