0
    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?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
sealz
  • 5,348
  • 5
  • 40
  • 70
  • Welcome to the site! Good practice for solving your own question is to actually post your own answer and then accept that (you can accept your own answer after the question has been active for two days) rather than editing your question so that it doesn't actually ask anything. So you might consider rolling the question back to the original or first edit, and then posting what you did as an answer. – erekalper May 13 '11 at 12:45
  • Furthermore, when someone answers a question to your liking (as it looks like they did [here](http://stackoverflow.com/questions/5980767/command-line-output-to-a-txt-file-java-exe-version-returning-blank)), click the checkmark next to it to declare it answered. This lets others know the problem has been solved, it gives credit to the person with the best answer, and shows that you're diligent about managing your account. – erekalper May 13 '11 at 12:47

1 Answers1

0

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
sealz
  • 5,348
  • 5
  • 40
  • 70