"Remote Access"

Solved/Closed
pushkar - Nov 29, 2008 at 06:18 AM
GiantLeap Posts 85 Registration date Saturday November 29, 2008 Status Member Last seen December 8, 2008 - Dec 2, 2008 at 02:28 AM
Hello,
hiii,

I want to remotely access the System details, actually i have found lots of server -client code.. but i want the java code for remotely accessing the system information in a LAN.I want the Java code so that i can easily monitor all the systems without any client side code or without installing any client side agent...is that possible....
i know that through WMI we can fetch each and every detail of the System...but i dont know how to connect to WMI using java code...if u cud help me..plz help me out.....

1 response

GiantLeap Posts 85 Registration date Saturday November 29, 2008 Status Member Last seen December 8, 2008 45
Dec 2, 2008 at 02:28 AM
Just enable "Remote Assistance" on your client PCs and use your "Remote Desktop" to access them

or use WMI through CreateObject as given at WMI Scripting https://docs.microsoft.com/en-us/previous-versions//aa393262(v=vs.85)?redirectedfrom=MSDN
[sRegTypes = new Array(
    "                              ",    // 0
    "REG_SZ                        ",    // 1
    "REG_EXPAND_SZ                 ",    // 2
    "REG_BINARY                    ",    // 3
    "REG_DWORD                     ",    // 4
    "REG_DWORD_BIG_ENDIAN          ",    // 5
    "REG_LINK                      ",    // 6
    "REG_MULTI_SZ                  ",    // 7
    "REG_RESOURCE_LIST             ",    // 8
    "REG_FULL_RESOURCE_DESCRIPTOR  ",    // 9
    "REG_RESOURCE_REQUIREMENTS_LIST",    // 10
    "REG_QWORD                    ");    // 11

HKLM = 0x80000002;
sRegPath = "SYSTEM\\CurrentControlSet\\Services\\Eventlog\\System";

try
{
    // VBScript: Set oLoc = CreateObject("WbemScripting.SWbemLocator")
    // JScript:
    oLoc = new ActiveXObject("WbemScripting.SWbemLocator");

    // VBScript: Set oSvc = oLoc.ConnectServer(null, "root/default")
    // JScript:
    oSvc = oLoc.ConnectServer(null, "root\\default");
    
    // VBScript: Set oReg = oSvc.Get("StdRegProv")
    // JScript:
    oReg = oSvc.Get("StdRegProv");
        

    //-------------------------------------------------------------
    // VBScript: E = oReg.EnumValues(HKLM, RegPath, sNames, aTypes)
    // JScript:
    oMethod = oReg.Methods_.Item("EnumValues");
    
    oInParam = oMethod.InParameters.SpawnInstance_();
    oInParam.hDefKey = HKLM;
    oInParam.sSubKeyName = sRegPath;
    oOutParam = oReg.ExecMethod_(oMethod.Name, oInParam);
    
    aNames = oOutParam.sNames.toArray();
    aTypes = oOutParam.Types.toArray();
    //-------------------------------------------------------------

    for (i = 0; i < aNames.length; i++)
        WScript.Echo("Type: ", sRegTypes[aTypes[i]],
            " KeyName: ", aNames[i]);
    
    // VBScript: E = oReg.GetMultiStringValue( _
    //     HKLM, RegPath, "Sources", sValues)
    // JSCript:
    oMethod = oReg.Methods_.Item("GetMultiStringValue");
    oInParam = oMethod.InParameters.SpawnInstance_();
    oInParam.hDefKey = HKLM;
    oInParam.sSubKeyName = sRegPath;
    oInParam.sValueName = "Sources";
    
    oOutParam = oReg.ExecMethod_(oMethod.Name, oInParam);
    
    aNames = oOutParam.sValue.toArray();
    //------------------------------------------------------------

    for (i = 0; i < aNames.length; i++)
        WScript.Echo("KeyName: ", aNames[i]);
}
catch(err)
{
    WScript.Echo("Error occurred\nCode: " + hex(err.number) + 
                          "Description: " + err.description);
}

//User-defined function to format error codes. 
//VBScript has a Hex() function but JScript does not.
function hex(nmb)
{
    if (nmb > 0)
        return nmb.toString(16);
    else
        return (nmb + 0x100000000).toString(16);
}
5