Solved

Shelling Command to run a Batchfile (WILL YOU EVER WORK???)

Posted on 2004-04-27
11
227 Views
Last Modified: 2010-05-02
Oh Masters of the universe :P


Hey all before you say that this is a simple shell to the command line to excute a batch file think again. The reason i can't just shell the file is that the batch file takes time to execute .. Between processes.. So i have to wait. So i decide to use SHELLEXECUTEINFO which waited for the process to finish as all you know. This worked great for me but then the batch file got bigger and this no longer works .... So now when the command prompt runs nothing happens .. Well the batchfile is run but then nothing ... It doesn't execute the file. If i click on the batchfile and run it everything works fine ....

Thanks in advance,

Simpson  
0
Comment
Question by:shutuplonnie
11 Comments
 

Author Comment

by:shutuplonnie
ID: 10931304
Hahahaha Whoops forgot the part where i need to say I need to be able to run this batchfile without clicking on it ...

Thanks guys ..


Simpson
0
 
LVL 1

Expert Comment

by:hal3000
ID: 10931759
Hi shutuplonnie,

SHELLEXECUTEINFO is a structure and not an executable command.

What are you using to execute the batchfile?

What platform are you running?

Good luck
0
 
LVL 11

Expert Comment

by:jmwheeler
ID: 10932157
Try This


Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Shell("C:\YourBatchFile.bat")

Do
   Do Events
Until FindWindow(vbNullString, "C:\WIN2000\system32\cmd.exe) = 0          'substitute the caption from the window that appears, this example is for Windows 2000


0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 11

Accepted Solution

by:
jmwheeler earned 250 total points
ID: 10932178
Sorry, Do Events should be no spaces.
 
ex.

Shell("C:\YourBatchFile.bat")
Do
   DoEvents
Until FindWindow(vbNullString, "C:\WIN2000\system32\cmd.exe) = 0          'substitute the caption from the window that appears, this example is for Windows 2000


This should stop your program until the batch file is done.
0
 
LVL 9

Expert Comment

by:p_sie
ID: 10932216
Use the ShellExecute API , Shell only works with exe-files !!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 10932281
0
 
LVL 11

Expert Comment

by:jmwheeler
ID: 10933517
p_sie, your wrong.  Shell works just fine with batch files.
0
 
LVL 9

Expert Comment

by:p_sie
ID: 10936403
From MSDN

Shell Function
Runs an executable program and returns a Variant (Double) representing the program's task ID if successful, otherwise it returns zero.
---------------------------------------------------
As it says : executable program , don't think a bat file is an executable program!
And I use ShellExecute and that works perfectly!
0
 
LVL 11

Expert Comment

by:jmwheeler
ID: 10943991
Regardless of what msdn says if you type in Shell("C:\Autoexec.bat") your program will run Autoexec.bat.
0
 
LVL 9

Expert Comment

by:p_sie
ID: 10947307
jmWheeler,

you are right I tried it and it worked, but in my memory I know I had trouble with the Shell function once, don't remember what, and since then
I am using ShellExecute and that works fine ...

0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question