Re: Shell Functions and DOS executables



Lance Wynn said

> Click: Project --> References and then select Windows Script
> Host Object Model from the reference list.

Thanks!

I followed the above and the DOS command executes perfectly!

However, the "results" string remains null whether the DOS command
was successful or unsuccessful?

###################
Here's a code snippet:

If Option_TDS7104.Value = True Then
' Insert TDS7104 routine here
' strXXX = MsgBox("Not yet implemented", vbCritical)

Dim wsh As IWshRuntimeLibrary.WshShell
Dim wshExec As IWshRuntimeLibrary.wshExec
Dim results As String

'Copy CNVRTWFM to User Directory
FileCopy (App.Path & "\" & "CNVRTWFM.EXE"), (File1.Path &
"\" & "CNVRTWFM.EXE")

ChDir File1.Path 'Change to USER directory

'Create DOS command string
strDOSCOMMAND = "cnvrtwfm -l " & File1.filename

Set wsh = New WshShell
Set wshExec = wsh.Exec(strDOSCOMMAND)
results = wshExec.StdOut.ReadAll
Debug.Print "results = "; results

End If
###################

This seems similar to the result of my attempt to redirect the DOS
Command output to a text file.

cnvrtwfm -l tek00001.wfm > test.txt
(at the Command Prompt) yields an EMPTY file.

dir > test.txt
(at the Command Prompt) yields a dir-dump to test.txt

It's as if this ancient DOS file conversion utility
(http://www.tek.com/site/sw/detail/1,1059,464,00.html)
somehow prevents a redirect?
###############

Any ideas?

Regards,

VB_Newby

> "VB_Newby" <VB_Newby@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:43d192b4$0$51452$892e7fe2@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>> "VB_Newby" <VB_Newby@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>>> news:43c05173$0$72436$892e7fe2
@authen.yellow.readfreenews.net...
>>>
>>> <Re-ordered for clarity>
>>>
>>> I'm running a DOS executable from a VB Shell function.
>>>
>>> If it's successful, it looks like this (at the DOS prompt):
>>> cnvrtwfm -l tek00001.wfm
>>> Creating tek00001.dat
>>>
>>>It it's unsuccessful, it looks like this (at the DOS prompt):
>>> cnvrtwfm -l tek00001.wfm
>>> Error Converting tek00001.wfm
>>>
>>> How can I retrieve the command line output of a Shell'ed DOS
>>> executable?
>
>> Lance Wynn said:
>> Hello,
>> Something along these lines may work for you.
>> (Make a reference in your project to the "Windows Script Host
>> Object Model")
>>
>> Dim wsh As IWshRuntimeLibrary.WshShell
>> Dim wshExec As IWshRuntimeLibrary.wshExec
>> Dim results as string
>> Set wsh = New WshShell
>> Set wshExec = wsh.Exec("c:\test.bat")
>> results = wshExec.StdOut.ReadAll
>
> Can someone further elaborate on how to integrate this into my VB
> program. I don't know how to "make a reference to a Windows
> Script Host Object Model". I'm just above clueless... but
> learning. ;-D
>
> (I tried redirecting the DOS command output via ">" but for some
> reason this silly DOS program won't be redirected to a file.)


.



Relevant Pages

  • NTVDM hard error on Windows 2003 Server SP1
    ... Windows 2003 Server SP1 platform, there is a pop-up box with the error ... run regedit.exe from a DOS window command prompt. ... The file "command" executes from the DOS command line, ...
    (microsoft.public.windows.server.general)
  • Re: DOS / XP bat file programming question
    ... How do I feed a "y" response to a DOS command that wants to prompt me ... Note that DOS is an operating system, same as Windows XP. ... There is no DOS under Windows, only a Command Prompt. ...
    (microsoft.public.windowsxp.general)
  • Re: Master Boot Record
    ... Is the DOS program relating to the commands which you mentioned in your ... > If you don't know why you'd want to restore or backup a boot sector then don't do it. ... It also contains the partition table. ... The LOCK command enables direct disk access by programs ...
    (microsoft.public.windowsxp.general)
  • Re: newbie: I/O with nasm
    ... A program that starts with "main" and is linked with gcc has the "_start" label in the C startup code, and the stack is slightly different when we get control at "main". ... Dos is *very* different, as you point out. ... Working on up the (Linux) stack, the list of command line argument pointers is terminated with a zero. ...
    (alt.lang.asm)
  • Re: "Read-only" Folders
    ... "Dos attrib command" - that's why. ... anti-Windows folks tell me that Windows is ...
    (microsoft.public.windowsxp.security_admin)