/* class RunApp runs win32 native application. Code for Netscape or Microsoft JVM. M. Gallant 05/09/2002 */ import com.ms.security.*; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.io.* ; import java.util.*; import netscape.security.PrivilegeManager; public class RunApp extends Applet implements ActionListener { TextArea ta = new TextArea (25, 80); Button startbutton = new Button("Start Application") ; private static String execommand = "C:\\windows\\notepad.exe" ; private String osname; public void init() { try { if (Class.forName("com.ms.security.PolicyEngine") != null) { // required for IE PolicyEngine.assertPermission(PermissionID.SYSTEM); } } catch (Throwable cnfe) { } this.setBackground(Color.white) ; startbutton.addActionListener(this) ; add(startbutton) ; startbutton.setBackground(Color.red) ; try{ PrivilegeManager.enablePrivilege("UniversalExecAccess") ; // required for NN } catch(Exception cnfe) { System.out.println("netscape.security.PrivilegeManager class not found") ; } osname = System.getProperty("os.name"); // if NT, Win2000 or WinXP, adjust path if(osname.equals("Windows NT") || osname.equals("Windows 2000")|| osname.equals("Windows XP")) execommand = "C:\\winnt\\notepad.exe" ; } public void actionPerformed(ActionEvent e) { if( (e.getActionCommand()).equals("Start Application")) { try{ PrivilegeManager.enablePrivilege("UniversalExecAccess") ; // required for NN } catch(Exception cnfe) { System.out.println("netscape.security.PrivilegeManager class not found") ; } try { Process proc = Runtime.getRuntime().exec(execommand) ; } catch(IOException ieo) { System.out.println("Problem starting " + execommand) ; } // System.out.println("execommand: " + execommand) ; } } }