VB to run Command for java.exe and output text to txt file
Private Sub Command1_Click()
Dim sCommand as String
Dim oWrite as System.IO.StreamWriter
sCommand = "cmd C:\Windows\System32\java.exe -version2> C:\Users\Desktop\version.txt"
oWrite = IO.File.CreateText(C:\Users\Desktop\version.txt
End Sub
When i run the command in the command prompt开发者_运维百科 it does what it is suppose to do (write to txt file. But when implemented into VB it will run and flash the command prompt but it will not write to a file.
Am I missing a line of something?
I was clearly making things way to complicated... This ended up working perfectly Fine.
Sub Main()
Dim sdkCommand As String
sdkCommand = "C:\Windows\System32\Java.exe -version 2> C:\Users\Desktop\JavaSDKInfo.txt && C:\Windows\System32\tasklist.exe /FI ""IMAGENAME eq java.exe"" >> C:\Users\Desktop\JavaSDKInfo.txt"
Shell("cmd.exe /c" & sdkCommand)
End Sub
精彩评论