private List<NativeWindowsSupport> getAvailableNativeWindowSupports() { List<NativeWindowsSupport> nativeWindowsSupports = new ArrayList<NativeWindowsSupport>(); if (NativeWindowsSupport.all() != null && !NativeWindowsSupport.all().isEmpty()) { for (Descriptor<NativeWindowsSupport> nativeWindowsSupport : NativeWindowsSupport.all()) { try { nativeWindowsSupports.add(nativeWindowsSupport.newInstance(null, null)); } catch (Throwable exc) { logger.info("Failed to instantiate Native Window Support - " + nativeWindowsSupport.getDisplayName()); } } } return nativeWindowsSupports; }
/** * Get the error associated with the last Native Unix Operation * * @return String error message */ public String getLastWindowsError() { if (!hasUnixSupport()) { return "Native Windows Support plugin not installed"; } return nativeWindowsSupport.getLastError(); }
/** * Find the Native Process Id of the given java.lang.process * * @param process (java.lang.process) * @return pid, the Native Process ID */ public int getWindowsProcessId(Process process) throws NativeAccessException { ensureWindowsSupport(NativeFunction.WINDOWS_PROCESS); return nativeWindowsSupport.getWindowsProcessId(process); }
/** * Check if .NET is installed on a the Windows machine * * @return true if .NET is installed. * @throws hudson.util.jna.Native.ExecutionError */ public boolean isDotNetInstalled(int major, int minor) throws NativeAccessException { ensureWindowsSupport(NativeFunction.DOTNET); return nativeWindowsSupport.isDotNetInstalled(major, minor); }
/** * Get all the native processes on a Windows System * * @return List of Native Window Processes * @throws hudson.util.jna.Native.ExecutionError */ public List<NativeProcess> getWindowsProcesses() throws NativeAccessException { ensureWindowsSupport(NativeFunction.WINDOWS_PROCESS); return nativeWindowsSupport.getWindowsProcesses(); }
/** * Move a Windows File using native win32 library * * @param fromFile * @param toFile * @return * @throws hudson.util.jna.Native.NativeExecutionException */ public void windowsMoveFile(File fromFile, File toFile) throws NativeAccessException { ensureWindowsSupport(NativeFunction.WINDOWS_FILE_MOVE); nativeWindowsSupport.windowsMoveFile(fromFile, toFile); }
/** * Run the Windows program natively in an elevated privilege * * @param winExe, windows executable to run * @param args, arguments to pass * @param logFile, File where the logs of the process should go * @param pwd, Path of the working directory * @return int, process exit code * @throws hudson.util.jna.Native.NativeExecutionException */ public int windowsExec(File winExe, String args, String logFile, File pwd) throws NativeAccessException { ensureWindowsSupport(NativeFunction.WINDOWS_EXEC); return nativeWindowsSupport.windowsExec(winExe, args, logFile, pwd); }
private void ensureWindowsSupport(NativeFunction function) throws NativeAccessException { if (!hasWindowsSupport()) { throw new NativeAccessException("Native Windows Support plugin not installed"); } if (!nativeWindowsSupport.hasSupportFor(function)) { throw new NativeAccessException("Installed Native Windows Support plugin does not support " + function); } }