My code is running command line DOS from a batch file and producing text file
output. The command needs be done before the text file is rewritten (else, user
gets old message). I'm using GetNumTasks function to test for this. Error occurs
at "Num_Apps = GetNumTasks()". The message is: "Run-Time error '53'; File not
found:Kernel".
Below is code:
====================================================
Private Declare Function GetNumTasks Lib "Kernel" () As Integer
Private Sub Command1_Click()
Dim Num_Apps As Integer, NewFile As Integer
Dim File_Data As String, DosCmd As String
Dim X As Integer
'Create a batch file with the DIR *.EXE command
'and redirect the output to a textfile DIRLIST.TXT.
DosCmd = "DIR c:\*.* > c:\DIRLIST.DAT"
NewFile = FreeFile
Open "C:\DIRBAT.BAT" For Output As #NewFile
Print #NewFile, DosCmd
Close #NewFile
'Call the Shell command to execute DIRBAT.BAT.
==>Num_Apps = GetNumTasks() <===========This is where error
occurs
X = Shell("C:\DIRBAT.BAT", 2)
'Wait until DIR has finished doing its thing.
Do While GetNumTasks() <> Num_Apps
X = DoEvents()
Loop
'Display the filenames in the Text Box.
NewFile = FreeFile
Open "C:\DIRLIST.DAT" For Input As #NewFile
Text1.Text = ""
While Not EOF(NewFile)
Line Input #NewFile, File_Data
Text1.Text = Text1.Text & File_Data & Chr(13) & Chr(10)
Wend
Close #NewFile
End Sub
Private Sub Command2_Click()
End
End Sub
====================================================
This program was used as a test base for other programs
which perform command line processing.
=====================================================
Any help will be appreciated
Steve A. [sig][/sig]
output. The command needs be done before the text file is rewritten (else, user
gets old message). I'm using GetNumTasks function to test for this. Error occurs
at "Num_Apps = GetNumTasks()". The message is: "Run-Time error '53'; File not
found:Kernel".
Below is code:
====================================================
Private Declare Function GetNumTasks Lib "Kernel" () As Integer
Private Sub Command1_Click()
Dim Num_Apps As Integer, NewFile As Integer
Dim File_Data As String, DosCmd As String
Dim X As Integer
'Create a batch file with the DIR *.EXE command
'and redirect the output to a textfile DIRLIST.TXT.
DosCmd = "DIR c:\*.* > c:\DIRLIST.DAT"
NewFile = FreeFile
Open "C:\DIRBAT.BAT" For Output As #NewFile
Print #NewFile, DosCmd
Close #NewFile
'Call the Shell command to execute DIRBAT.BAT.
==>Num_Apps = GetNumTasks() <===========This is where error
occurs
X = Shell("C:\DIRBAT.BAT", 2)
'Wait until DIR has finished doing its thing.
Do While GetNumTasks() <> Num_Apps
X = DoEvents()
Loop
'Display the filenames in the Text Box.
NewFile = FreeFile
Open "C:\DIRLIST.DAT" For Input As #NewFile
Text1.Text = ""
While Not EOF(NewFile)
Line Input #NewFile, File_Data
Text1.Text = Text1.Text & File_Data & Chr(13) & Chr(10)
Wend
Close #NewFile
End Sub
Private Sub Command2_Click()
End
End Sub
====================================================
This program was used as a test base for other programs
which perform command line processing.
=====================================================
Any help will be appreciated
Steve A. [sig][/sig]