/** * Returns true if the .NET framework of the given version (or greater) is installed. */ public static boolean isInstalled(int major, int minor) { try { // see http://support.microsoft.com/?scid=kb;en-us;315291 for the basic algorithm // observation in my registry shows that the actual key name can be things like "v2.0 SP1" // or "v2.0.50727", so the regexp is written to accommodate this. RegistryKey key = RegistryKey.LOCAL_MACHINE.openReadonly("SOFTWARE\\Microsoft\\.NETFramework"); try { for( String keyName : key.getSubKeys() ) { if (matches(keyName, major, minor)) return true; } return false; } finally { key.dispose(); } } catch (JnaException e) { if(e.getErrorCode()==2) // thrown when openReadonly fails because the key doesn't exist. return false; throw e; } }
/** * Returns true if the .NET framework of the given version (or grater) is installed * on a remote machine. */ public static boolean isInstalled(int major, int minor, String targetMachine, IJIAuthInfo session) throws JIException, UnknownHostException { IJIWinReg registry = JIWinRegFactory.getSingleTon().getWinreg(session,targetMachine,true); JIPolicyHandle hklm=null; JIPolicyHandle key=null; try { hklm = registry.winreg_OpenHKLM(); key = registry.winreg_OpenKey(hklm,"SOFTWARE\\Microsoft\\.NETFramework", IJIWinReg.KEY_READ ); for( int i=0; ; i++ ) { String keyName = registry.winreg_EnumKey(key,i)[0]; if(matches(keyName,major,minor)) return true; } } catch (JIException e) { if(e.getErrorCode()==2) return false; // not found throw e; } finally { if(hklm!=null) registry.winreg_CloseKey(hklm); if(key!=null) registry.winreg_CloseKey(key); registry.closeConnection(); } }
/** * Returns true if the .NET framework of the given version (or greater) is installed. */ public static boolean isInstalled(int major, int minor) { try { // see http://support.microsoft.com/?scid=kb;en-us;315291 for the basic algorithm // observation in my registry shows that the actual key name can be things like "v2.0 SP1" // or "v2.0.50727", so the regexp is written to accommodate this. RegistryKey key = RegistryKey.LOCAL_MACHINE.openReadonly("SOFTWARE\\Microsoft\\.NETFramework"); try { for( String keyName : key.getSubKeys() ) { if (matches(keyName, major, minor)) return true; } return false; } finally { key.dispose(); } } catch (JnaException e) { if(e.getErrorCode()==2) // thrown when openReadonly fails because the key doesn't exist. return false; throw e; } }
/** * Returns true if the .NET framework of the given version (or greater) is installed. */ public static boolean isInstalled(int major, int minor) { try { // see http://support.microsoft.com/?scid=kb;en-us;315291 for the basic algorithm // observation in my registry shows that the actual key name can be things like "v2.0 SP1" // or "v2.0.50727", so the regexp is written to accomodate this. RegistryKey key = RegistryKey.LOCAL_MACHINE.openReadonly("SOFTWARE\\Microsoft\\.NETFramework"); try { for( String keyName : key.getSubKeys() ) { if (matches(keyName, major, minor)) return true; } return false; } finally { key.dispose(); } } catch (JnaException e) { if(e.getErrorCode()==2) // thrown when openReadonly fails because the key doesn't exist. return false; throw e; } }
/** * Returns true if the .NET framework of the given version (or greater) is installed. */ public static boolean isInstalled(int major, int minor) { try { // see http://support.microsoft.com/?scid=kb;en-us;315291 for the basic algorithm // observation in my registry shows that the actual key name can be things like "v2.0 SP1" // or "v2.0.50727", so the regexp is written to accomodate this. RegistryKey key = RegistryKey.LOCAL_MACHINE.openReadonly("SOFTWARE\\Microsoft\\.NETFramework"); try { for( String keyName : key.getSubKeys() ) { if (matches(keyName, major, minor)) return true; } return false; } finally { key.dispose(); } } catch (JnaException e) { if(e.getErrorCode()==2) // thrown when openReadonly fails because the key doesn't exist. return false; throw e; } }
/** * Returns true if the .NET framework of the given version (or grater) is installed * on a remote machine. */ public static boolean isInstalled(int major, int minor, String targetMachine, IJIAuthInfo session) throws JIException, UnknownHostException { IJIWinReg registry = JIWinRegFactory.getSingleTon().getWinreg(session,targetMachine,true); JIPolicyHandle hklm=null; JIPolicyHandle key=null; try { hklm = registry.winreg_OpenHKLM(); key = registry.winreg_OpenKey(hklm,"SOFTWARE\\Microsoft\\.NETFramework", IJIWinReg.KEY_READ ); for( int i=0; ; i++ ) { String keyName = registry.winreg_EnumKey(key,i)[0]; if(matches(keyName,major,minor)) return true; } } catch (JIException e) { if(e.getErrorCode()==2) return false; // not found throw e; } finally { if(hklm!=null) registry.winreg_CloseKey(hklm); if(key!=null) registry.winreg_CloseKey(key); registry.closeConnection(); } }
/** * Returns true if the .NET framework of the given version (or grater) is installed * on a remote machine. */ public static boolean isInstalled(int major, int minor, String targetMachine, IJIAuthInfo session) throws JIException, UnknownHostException { IJIWinReg registry = JIWinRegFactory.getSingleTon().getWinreg(session,targetMachine,true); JIPolicyHandle hklm=null; JIPolicyHandle key=null; try { hklm = registry.winreg_OpenHKLM(); key = registry.winreg_OpenKey(hklm,"SOFTWARE\\Microsoft\\.NETFramework", IJIWinReg.KEY_READ ); for( int i=0; ; i++ ) { String keyName = registry.winreg_EnumKey(key,i)[0]; if(matches(keyName,major,minor)) return true; } } catch (JIException e) { if(e.getErrorCode()==2) return false; // not found throw e; } finally { if(hklm!=null) registry.winreg_CloseKey(hklm); if(key!=null) registry.winreg_CloseKey(key); registry.closeConnection(); } }
/** * Returns true if the .NET framework of the given version (or grater) is installed * on a remote machine. */ public static boolean isInstalled(int major, int minor, String targetMachine, IJIAuthInfo session) throws JIException, UnknownHostException { IJIWinReg registry = JIWinRegFactory.getSingleTon().getWinreg(session,targetMachine,true); JIPolicyHandle hklm=null; JIPolicyHandle key=null; try { hklm = registry.winreg_OpenHKLM(); key = registry.winreg_OpenKey(hklm,"SOFTWARE\\Microsoft\\.NETFramework", IJIWinReg.KEY_READ ); for( int i=0; ; i++ ) { String keyName = registry.winreg_EnumKey(key,i)[0]; if(matches(keyName,major,minor)) return true; } } catch (JIException e) { if(e.getErrorCode()==2) return false; // not found throw e; } finally { if(hklm!=null) registry.winreg_CloseKey(hklm); if(key!=null) registry.winreg_CloseKey(key); registry.closeConnection(); } }