
VB4 - problem creating text from redirected output of shell command
Hoping this is a novice question, since that would be me -
I am trying to set up an app to
run the 'net start' command
redirect it to a file in the temp directory
then check each line of that file and compare it against variable set in the
app
if the line equals the variable, set the value of that service status to
true
I have a problem creating the file and if I create it outside the app, I
have problems with carriage returns. The variable are also be shown in a
text box and show the correct NT syntax but I get no file. When I bring in
the file, it does not show CR but instead shows a box in between each
service. When I modify the line input command to add Chr$(13), it just adds
the same box.
below is my code - All of the variable are defined in the form(load)
I appreciate any direction - thanks
txtConsole.Text = ""
FtpStatus = False
AdminStatus = False
NtLmStatus = False
wwwStatus = False
If FtpStatus = False Then lblFtpStatus(2).Visible = True
If AdminStatus = False Then lblAdminStatus(2).Visible = True
If NtLmStatus = False Then lblNtlmStatus(2).Visible = True
If wwwStatus = False Then lblWWWStatus(2).Visible = True
' Open the shell to run the net start command which will redirect the
output to a file
retval = Shell(valRun, 0)
' Read the file to determine which of the Web Services are running
Open valWCNT For Input As #1
' Show the file in the console window
Do Until EOF(1)
Line Input #1, valStartedServices
txtConsole.Text = txtConsole.Text & vbCr & valStartedServices
Loop
' If the service name is present in the file, therefore running, set the
status to True
Do Until EOF(1) ' Check for end of file.
Line Input #1, service ' Read line of data.
txtConsole.Text = service
If service = valFTP Then FtpStatus = True
If service = valAdmin Then AdminStatus = True
If service = valNTLM Then NtLmStatus = True
If service = valWWW Then wwwStatus = True
Loop
' Close the file
Close #1
' Delete the file
'TESTING BEGIN
'Kill valWCNT
'TESTING END
' Show status of services
' Hide Unkown Statuses
lblFtpStatus(2).Visible = False
lblAdminStatus(2).Visible = False
lblNtlmStatus(2).Visible = False
lblWWWStatus(2).Visible = False
If FtpStatus = True Then
lblFtpStatus(0).Visible = True
Else
lblFtpStatus(1).Visible = True
End If
If AdminStatus = True Then
lblAdminStatus(0).Visible = True
Else
lblAdminStatus(1).Visible = True
End If
If NtLmStatus = True Then
lblNtlmStatus(0).Visible = True
Else
lblNtlmStatus(1).Visible = True
End If
If wwwStatus = True Then
lblWWWStatus(0).Visible = True
Else
lblWWWStatus(1).Visible = True
End If
' Update Time
lblUpdateTime.Caption = "Last Updated " & " " & Now()
Exit Sub