You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by new_bie_tomcat <sw...@cisco.com> on 2008/09/02 08:13:55 UTC
UnauthorizedAccessException error while running WMI in tomcat
I have written the following code in Java to access registry of a remote
machine. I am able to execute the program successfully when i run the
program separately. But when I try to execute the code in Apache Tomcat. I
am getting
UnauthorizedAccessException error.The full text of error is
System.UnauthorizedAccessException: Access to the registry key is denied. at
Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str) at
Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive hKey, String
machineName) at BOMInfoCollector.BOMInfoCollector.getOSVersion(StreamWriter
file, String remoteName)
Following is the Java code: try { String keykey =
"C:\\Diagnostic\\DiagnosticAssayRE\\Executable\\BOMInfoCollector.exe";
String ipadddress = Remote machine's IP; String keyStr1= keykey + " " +
ipadddress;
Process p = Runtime.getRuntime().exec(keyStr1);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output from the command
while ((s = stdInput.readLine()) != null)
{
response = response + s +"\n";
}
while ((s = stdError.readLine()) != null)
{
response = response + s +"\n";
System.out.println(s);
}}catch(Exception e){
System.out.println("Exception occured "+e);
}
Following is the C# code whose name is
string osKeyName = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
try{
RegistryKey hklm = RegistryKey.OpenRemoteBaseKey(
RegistryHive.LocalMachine, remoteName);
RegistryKey osKey = hklm.OpenSubKey(osKeyName);
if(osKey != null) {
object prodName = osKey.GetValue("ProductName");
Console.WriteLine("OSName=" + prodName);
}
Console.WriteLine("Exiting getOSVersion() method");
}catch(System.UnauthorizedAccessException e){
Console.WriteLine("You are not authorized to access the machine.Please check
the network Privileges "+e);
}catch(Exception e){
Console.WriteLine("Error occured "+e);
} Please let me know what can be the possible problem.
--
View this message in context: http://www.nabble.com/UnauthorizedAccessException-error-while-running-WMI-in-tomcat-tp19264675p19264675.html
Sent from the Tomcat - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: UnauthorizedAccessException error while running WMI in tomcat
Posted by new_bie_tomcat <sw...@cisco.com>.
I guess i have posted in the wrong forum. I have again created a new post in
Tomcat-user..
Thanks..
Swati..
Mark Thomas-18 wrote:
>
> new_bie_tomcat wrote:
>
>> } Please let me know what can be the possible problem.
>
> Please as this question on the users list.
>
> Mark
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/UnauthorizedAccessException-error-while-running-WMI-in-tomcat-tp19264675p19365856.html
Sent from the Tomcat - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: UnauthorizedAccessException error while running WMI in tomcat
Posted by Mark Thomas <ma...@apache.org>.
new_bie_tomcat wrote:
> } Please let me know what can be the possible problem.
Please as this question on the users list.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org