Hi good Afternoon,
I am trying to check some particular windows services running or stop remotely throw
java program that program works fine in local system and give the out put but when i put Ip address of remote machine that is not showing anything thing but in command prompt it display the output of remote computer not in java program, My java program is like that
package com.sadhu;
import java.sql.*;
import java.io.*;
import java.text.*;
public class CheckServices
{
public static void main(
String args[])
{
try
{
Process p=Runtime.getRuntime().exec("sc query ALG");
BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=reader.readLine();
while(line!=null)
{
if(line.trim().startsWith("STATE"))
{
if (line.trim().substring(line.trim().indexOf(":")+1,line.trim().indexOf(":")+4).trim().equals("1"))
System.out.println("Stopped");
else
if (line.trim().substring(line.trim().indexOf(":")+1,line.trim().indexOf(":")+4).trim().equals("2"))
System.out.println("Startting....");
else
if (line.trim().substring(line.trim().indexOf(":")+1,line.trim().indexOf(":")+4).trim().equals("3"))
System.out.println("Stopping....");
else
if (line.trim().substring(line.trim().indexOf(":")+1,line.trim().indexOf(":")+4).trim().equals("4"))
System.out.println("Running");
}
line=reader.readLine();
}
}
catch(IOException e1) { }
}
}
It works fine for Local system but not working for remote server , i put command line "sc \\43.45.46.100 query ALG" it display the status of Remote Services ,When i put "sc \\43.45.46.100 query ALG" in place of "sc query ALG" then it is not working or not showing anything
Thanks in Advance
SCP