RATE THIS ANSWER
0
Click to Vote:
0
0
Googling I found this (http://www.rgagnon.com/javadetails/java-0014.html) so I'd suppose that if you adjust the code below:
========
import java.io.*;
public class CmdExec {
public static void main(String argv[]) {
try {
String line;
Process p = Runtime.getRuntime().exec
(System.getenv("windir") +"\\system32\\"+"tree.com /A");
BufferedReader input =
new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
}
input.close();
}
catch (Exception err) {
err.printStackTrace();
}
}
}
========
By changing:
Process p = Runtime.getRuntime().exec
(System.getenv("windir") +"\\system32\\"+"tree.com /A");
in
Process p = Runtime.getRuntime().exec
(System.getenv("windir") +"\\system32\\"+"wscript.exe c:\yourscript.vbs hosttocheck");
coule lead you to the solution.
In the vbscript I suggest you to use command-line arguments in order to be able to pass the remote host's name/ip
E.g.
' VbScript code
Dim HostToCheck
Set objArgs = WScript.Arguments
If objArgs.Count > 0 Then
HostToCheck = objArgs(0)
End If
....
I hope this helps