Ok, first of all, i'm quite sure that exception does not exist in Java nor in 
Tomcat! (as far as I know it's not in the apis), yet it does exists in .Net. So 
my gess is that it's a .Net exception after all
and you are just reading it from the console.

you may want to try giving more privileges to the tomcat service so that it 
run's the .net program with more privileges too.

BYE!

ps: excuse my english, it's not my mother's tonge.

----- Mensaje original ----
De: new_bie_tomcat <[EMAIL PROTECTED]>
Para: users@tomcat.apache.org
Enviado: lunes 8 de septiembre de 2008, 1:59:04
Asunto: 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 if any configuration is needed in Tomcat to support this? 
-- 
View this message in context: 
http://www.nabble.com/UnauthorizedAccessException-error-while-running-WMI-in-tomcat-tp19365845p19365845.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


      
____________________________________________________________________________________
¡Buscá desde tu celular!

Yahoo! oneSEARCH ahora está en Claro

http://ar.mobile.yahoo.com/onesearch

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to