Search code examples
shelllotusscriptpgp

How to Run Shell function (LotusScript Language) in Full Administrator


I need to process PGP command line codes using the Shell function (LotusScript Language) in Full Administrator. I manually tried the pgp commands using CMD line and I have confirmed the issue is the Administrator rights. So how do I trigger the Shell function to run in Administrator mode?


Solution

  • Fixed the issue by modifying the Java Policy and was able to run the Shell command using JAVA agent. 
    
    
        import lotus.domino.*;
        import java.util.*;
        import java.io.*;
    
    
        public class PGPCodeBuilderEngine { 
    
            /**
             * Creates  Encoded  PGP  file from the specified Input file
             */
    
            public void EncodeFile(String inputFolder, 
    String inputName, String outputFolder, 
    String outputName,  String passName)
            {    
    
                try{
    
                    String[] cmd = new String[3];
                    cmd[0] = "cmd.exe" ;
                    cmd[1] = "/c" ;
                    cmd[2] = "pgp --encrypt " + inputFolder + "/" + 
    inputName + " --recipient " + passName +
     " --input-cleanup wipe --output " +  outputFolder + "/" + 
                    outputName + " --overwrite wipe --status-file " + 
    outputFolder + "\\status.log -v";
    
                    // must be run with unrestricted access
                    Runtime rt = Runtime.getRuntime();
                    Process proc = rt.exec(cmd);
    
                    cmd = null;
                    rt = null;
                    proc = null;
    
                } catch(Exception e) {
                    e.printStackTrace();
                }finally{
                    System.gc();
                }
    
            }   
    
        }