Beginner's questions: running programs

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I'm currently interested in learning vbscript for the same purposes as
batch language: manipulating files and running programs from a DOS
prompt.

The following code performs DIR and shows the output. Is this a good
pattern for most non-interactive DOS programs, or is there a simpler
or more efficient way? To be complete, a similar loop would be needed
for stderr output as well, and I haven't even experimented with stdin
yet:

------------------------
' For use with cscript
' Demonstrates how to run a command-line program and show its output
' without opening a new window
Dim oWsh, oX
Set oWsh = Wscript.CreateObject("Wscript.Shell")
set oX = oWsh.exec("%comspec% /C dir")
Do until oX.stdOut.AtEndOfstream
Wscript.echo oX.stdout.readline()
loop
------------------------
If the DOS program returns an errorlevel code, how is that accessed?

Another question (and this is a real reason for learning an
alternative to batch):

I have a batch file that runs a MS-Access macro (among other
tasks). This line is:

C:\Progra~1\Micros~1\Office\MSACCESS ttf /xdupcrcs

(ttf is the database and dupcrcs is the name of the macro).

It runs fine on my machine except that when Access
finishes, I'm returned to the desktop rather than
the DOS window, and the batch file does not continue.

How would I start up Access in VBscript, run that macro, and continue
the script without any interruptions?

In general, what book or web site would you recommend studying for
this kind of use of VBscript? I have _VBScript_in_a_Nutshell_, which
is indispensible but sketchy; and _VBScript_ 2nd ed. by Adrian
Kingsley-Hughes et al. (published by Wrox). This book is
altogether disappointing: badly organized and sometimes
poorly written and with errors. It concentrates on clients, servers,
COM objects, and Web applications. That is all irrelevant for me just
now. I'd like to find something more detailed and elementary for my
present needs.

Thank you!

.



Relevant Pages

  • Re: Copying files based on date during logon
    ... Most of us will have deduced more about your scripting acumen from your ... Batch is more hands-on with the o/s than ... VBScript is the exact opposite - a general purpose programming environment ...
    (microsoft.public.windows.server.scripting)
  • Re: Multi-zip files -- Windows server
    ... native DOS versions). ... TO BATCH OR NOT TO BATCH ... and using a batch file to try and solve the problem... ... The IBM PC operating system command line is a most ...
    (comp.sys.cbm)
  • Re: Is VbScript to be discontinued by Microsoft
    ... converted to batch than to powershell, ... likely be better in powershell. ... There was a time when vbscript was envisioned as a ... You'd think vbscript would win in this area because it runs on more windows ...
    (microsoft.public.scripting.vbscript)
  • Re: An end to tweaking?
    ... > Batch File Lab Notes, which had so much info it boggled my mind. ... Doing /anything/ recursive with DOS batch makes my head hurt. ... bash (the default shell under Linux) is /much/ better than ... You can save that to a file and it will be a first-class command from then ...
    (comp.os.linux.misc)
  • Re: Help with VPN Client and Cached Credentials, please!
    ... wants to VPN back into the network to access network shares as ... he's prompted for username and password. ... VBScript or batch even..) ...
    (microsoft.public.windowsxp.work_remotely)