Click to See Complete Forum and Search --> : How get the prompt information?


visual fzz
January 21st, 2000, 08:53 AM
Exemple:
You have a environmental variable called "MYVAR" and its value is "c:\MyFolder\VB"
if you enter "set myvar" at the dos prompt, the windows displays "MYVAR=c:\MyFolder\VB"

HOW can I get the line "MYVAR=c:\MyFolder\VB" with vb code??
This is an example, I know that the Environ function return environmental variables.

But generally, I want to get the prompt returned information (scanf in C...)

Fzz

Bruno
January 21st, 2000, 11:40 AM
redirect result to a textfile:

option Explicit

private Sub Form_Click()
Dim sLine as string, Msg as string
' execute command
Shell "command.com /c " & "set > c:\info.txt"
'Shell "command.com /c " & "dir/w > c:\info.txt"

DoEvents

' read file
Open "c:\info.txt" for input as #1
Do While Not EOF(1)
Line input #1, sLine
Msg = Msg & sLine & vbCrLf
Loop
Close #1

MsgBox Msg ' show result
End Sub



Note:
you can add pause after Shell, or you can use some advanced code to ShellAndWait

January 21st, 2000, 01:25 PM
You can use this function;

Environ({envstring | number})

as in

myVar = environ("MYVAR")