PDA

View Full Version : Shell Cmd Works on Some Computers, But Not Others



aerodoc
10-28-2010, 09:00 AM
On some computers/companies, the shell command will not run.

I am using this code, but have used other approaches to call a windows command shell:
http://www.cpearson.com/excel/ShellAndWait.aspx

It stops here, which may give an better idea about why it won't run the command shell:

ProcHandle = OpenProcess(SYNCHRONIZE, False, TaskID)
If ProcHandle = 0 Then
ShellAndWait = ShellAndWaitResult.Failure
Exit Function
End If

My best guess is that this computer system/company has incorporated something that restricts Excel VBA from actually running the shell command. Perhaps this is set by IT or anti-virus, etc.? I suppose this might be a security measure/setting?

austenr
10-28-2010, 10:23 AM
Your probably right. Depends on the security the company has set up. Companies are getting very aware of stuff that they dont know that might compromise their systems.

BTW, you say it runs on some computers but not others. Do you mean some companies and not others. If thats the case then your suspicions are most likely correct.

aerodoc
10-28-2010, 10:49 AM
Yes, I should be more careful and say that it is company specific, not user specific within a company.

I can see how a company might want to restrict access since one could write a malicious shell command (i.e. delete the c: drive) and they probably want to protect against this.

What can be done to at least understand the problem and perhaps direct the user for a way to disable it. I suppose this may be more of an IT question than a direct VBA question. This could be quite a sticking point.