Re: Shell Functions and DOS executables
- From: "VB_Newby" <VB_Newby@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: 21 Jan 2006 04:41:34 GMT
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.)
.
- Follow-Ups:
- Re: Shell Functions and DOS executables
- From: Lance Wynn
- Re: Shell Functions and DOS executables
- References:
- Shell Functions and DOS executables
- From: VB_Newby
- Re: Shell Functions and DOS executables
- From: Lance Wynn
- Re: Shell Functions and DOS executables
- From: VB_Newby
- Re: Shell Functions and DOS executables
- From: Lance Wynn
- Shell Functions and DOS executables
- Prev by Date: Re: UDT in Collection
- Next by Date: Re: OT: Recommend web host
- Previous by thread: Re: Shell Functions and DOS executables
- Next by thread: Re: Shell Functions and DOS executables
- Index(es):
Relevant Pages
|