Subject: Problem to run batch files from VB application
Posted By: Dmitriy Post Date: 4/10/2006 2:14:40 PM
Hello Experts,
I am having a problem to run the batch file using Shell() function from inside VB6 application. I've created this application on my Windows XP Pro. PC and it is working perfectly. But after I moved the EXE to the Windows 2000 Server PC, the Shell("Program.BAT",vbMinimaized) line of code stopped working(it does not do anything???). What is going on? I am completely frustrated. Why the standard VB Shell() function does not work on the server PC?

Any suggestions will be appreciated and thanks in advance.

-Dmitriy
Reply By: BrianWren Reply Date: 4/21/2006 3:56:12 PM
Perhaps the process requires a user interface, and being run on a server it cannot gain access to anything that acts like a screen

Perhaps the .bat is actually running, but is running in a separate virtual machine that is spawned to handle the process, so no results show in the process that triggered that spawning of a virtual machine.

If Shell returns a result that might be useful;  I’d try to obtain that result to try to get a view into what’s going on.  (Seems to me it returns a handle to the window that got started, I forget just now.)

See if you can get a ‘pause’ into the batch file, then use CTRL+ALT+DEL to use task manager to see if there is a process associated with the shell command that was invoked.

I suppose reverting to XP is out of the question...  :¬\
Reply By: Dmitriy Reply Date: 4/22/2006 6:29:33 AM
Brian,

Thanks for reply. This Shell() function return the value Nothing. I forgot to tell that this BAT file I am trying to run suppose to do some FTP action to move files to the FTP site. And when I run this BAT file by itself on the server, it is running OK. Also, I've created a couple of NT services in VB6.0 which are using same Shell() function. Those services are working perfectly on the same server?
So, this is a strange "miracle"?

-Dmitriy
Reply By: kmsdove Reply Date: 5/3/2006 1:39:57 PM
I too am having a similar problem.  I created the database on my laptop at home on XP and have sinced moved it to the server at work.  The server is W2K.  The command actually worked for a while and then all of a sudden quit working.  I am not sure what to do at this point to get the shell command to work.  I have tried changing the bat to notepad.exe just to see if it was working and to no avail.

Any suggestions

Kathy S.
Reply By: BrianWren Reply Date: 5/5/2006 10:56:14 AM
I wonder if maybe this is a security issue...  I wonder if the credentials that the non-functioning Shell function is using have no rights to the .bat resources?
Reply By: Dmitriy Reply Date: 5/8/2006 7:07:01 AM
Hi Brian,

How to check credentials that the non-functioning Shell function is using? This BAT file is located in same directory where the application (which is using the Shell function) is staying.

-Dmitriy
Reply By: remi_pan Reply Date: 9/8/2006 3:31:07 PM
Hello everybody,

I'm having just the same problem : trying to call a batch file, containing ftp command, give nothing.
The code is as follow (I did not actually wrote it myself):


X = 0
On Error Resume Next
X = Shell(App.Path & "\EnvoyerOF.bat ENVOI.xml")
If X = 0 Then
   'sending failed
Else
   'sending succeed
endif


We have of course verified right permission for the batch file... Furthermore, we tryed to replace its contents with a dumb call to cmd.exe: nothing happen... So this batch script is not executed;

One first hypothesis was about a path error. But if that file is suppressed, then the return value of shell goes to zero (showing that the invocation failed). So the path seem to be right, even if it isn't quote-protected...
Maybe some error about a space character in "C:\Program Files". Weird error anyway, as the call to Shell() doesn't return zero.

Then, we thought about security protection... There is actually some security checking when calling "unmannaged code"... But that's in .NET ! (http://msdn2.microsoft.com/en-us/library/xe736fyk.aspx) This seem farfetched...

Finaly, one point is that the code run well on the machine where VisualStudio was installed... But not on our machine, where VS is *not* installed... Perhaps something about different version of a library, or a library installed with VS, that's not present on our production machine. But again, as Shell is something very basic, that seem farfetched.

--
Remi

Reply By: kan_lenny Reply Date: 9/13/2006 11:42:38 AM
Hi,
i also had similar issue where we are using Shell command to open any document. It was working fine and stopped working all of sudden on my W2K machine. Visual Studi is not installed on my box. I'm using the Executable placed on different server to run the application on my machine. When i run the older version of this executable which on different server works fine but the current Executable on different server has the problem.
Did any one find fix for this? Do we have to apply any patch? if i have to, is it on the Server machine where the Executable is placed or my client machine where it is running?
Please let me know if any one finds the solution. Your help is highly appreciated.

--

Lenny

Go to topic 49691

Return to index page 176
Return to index page 175
Return to index page 174
Return to index page 173
Return to index page 172
Return to index page 171
Return to index page 170
Return to index page 169
Return to index page 168
Return to index page 167