Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 10th, 2006, 02:14 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 121
Thanks: 1
Thanked 0 Times in 0 Posts
Default Problem to run batch files from VB application

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
 
Old April 21st, 2006, 03:56 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

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... :¬\
 
Old April 22nd, 2006, 06:29 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 121
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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
 
Old May 3rd, 2006, 01:39 PM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kmsdove
Default

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.
 
Old May 5th, 2006, 10:56 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

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?
 
Old May 8th, 2006, 07:07 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 121
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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
 
Old September 8th, 2006, 03:31 PM
Registered User
 
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to remi_pan Send a message via Yahoo to remi_pan
Default

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):

Code:
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

 
Old September 13th, 2006, 11:42 AM
Registered User
 
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kan_lenny
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Run a MS DOS Batch file from Excel VBA Louh Excel VBA 1 March 4th, 2008 10:02 PM
Convert a batch file to run in VBscript - WSH issu malcomm VBScript 0 October 25th, 2006 12:35 AM
Problem to run batch files from VB Application Dmitriy Pro VB 6 4 April 13th, 2006 02:27 AM
Files needed to run a VB.Net Windows Apps daniel VB.NET 2002/2003 Basics 2 October 15th, 2004 09:29 AM
Run vb application automatically PbsiGuru General .NET 3 March 17th, 2004 04:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.