Shell cmd in access vba returns error 5 - invalid

2019-09-15 18:25发布

I have used the Shell command in MS Access for several years in multiple databases in various versions. Most recently, I have received this Run-Time error 5 - invalid procedure call or argument on a Shell command I have used for many years. Can anyone tell me if there was a recent Windows update or possibly MS Office update that has caused this error to appear? I am currently using Office 2010 and Office 2013 and receiving the same error in both version on multiple computers. I have even tried creating a simple empty database and gone straight to the vba window and in the immediate window tried a simple Shell command as such:

Shell "C:\Notepad.bat", vbNormalFocus  

Notepad.bat is a simple command inside it:

cmd /C "Notepad.exe"

The code:

Shell "Notepad.exe", vbNormalFocus 

does work, but:

Shell "Cmd.exe", vbNormalFocus 

still gives the same Error 5 message on every machine I test it on. Running the batch files from the Windows explorer works just fine. Any help is much appreciated.

1条回答
男人必须洒脱
2楼-- · 2019-09-15 18:43

After a lot more investigation, I happened on a new software installed by our network software engineers that maintain our McAfee protection. Last week, there was a blind install of a new app called Adaptive Threat Protection and is set to check for MS office apps running shell commands, especially the CMD type. This is set to automatically block all of these such commands. I finally came to a conclusion to look in anything recently installed or updated on my computer and happen to find a few different things installed within the last week date range. Thank you for your assistance and answers so far. The answer provided by thx1138v2 were something I also tried prior to my post but I figured for my 1st question I tried to keep my post to a bit of a minimum.

查看更多
登录 后发表回答