View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Ken Macksey Ken Macksey is offline
external usenet poster
 
Posts: 77
Default Running a batch file from VB

Hi

Use something like this to select the drive and dir you want.

ChDrive "D" ' be sure you are logged on to the drive you want, in this
case drive "D"
ChDir "\my music" ' change to the dir you want to be in, starting first at
the root dir (the \)


MsgBox CurDir ' show me where I am


To close the dos window after the batch file ends, I assume you are using
win 98 since win xp seems to do this as the default.

After running the batch file, with the dos window open, right click on the
dos window title bar. Select properties. On one of the tabs(I forget which
one and am not on a win 98 system) you will see a checkbox with the caption
" Close on Exit". Check the checkbox. Click apply. Click OK.

Now it should close automatically after it finishes running.


HTH

Ken M



"Graham Carter" wrote in message
...
I am trying to execute a batch file from visual basic.
While the VB help suggests ways to execute DLL or enable
OLE objects, these are well beyond my skill area. I can't
find anything specific in help to allow me to run a batch
file automatically.

When running the program manually, I open a command prompt
window and run the batch file from there. I would like to
automate this from Excel.

Thx in advance, GC
p.s. How do you search the newsgroup aside from scrolling
through the postings?



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003