• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

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

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
shutuplonnie
Asked:
shutuplonnie
1 Solution
 
shutuplonnieAuthor Commented:
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
 
hal3000Commented:
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
 
jmwheelerCommented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jmwheelerCommented:
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
 
p_sieCommented:
Use the ShellExecute API , Shell only works with exe-files !!
0
 
David LeeCommented:
0
 
jmwheelerCommented:
p_sie, your wrong.  Shell works just fine with batch files.
0
 
p_sieCommented:
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
 
jmwheelerCommented:
Regardless of what msdn says if you type in Shell("C:\Autoexec.bat") your program will run Autoexec.bat.
0
 
p_sieCommented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now