run vbscript on remote computer from java

10 pts.
Tags:
Java
Remote computer
VBScript
How do I run vbscript on remote computer from java application?
ASKED: May 14, 2008  6:09 AM
UPDATED: May 14, 2008  8:26 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following