Package hudson.os
Class WindowsUtil
java.lang.Object
hudson.os.WindowsUtil
Utilities for the Windows Platform.
Adapted from:
Everyone quotes command line arguments the wrong way
- Since:
- 2.183
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FilecreateJunction(File junction, File target) Creates an NTFS junction point if supported.static ProcessExecutes a command and arguments usingcmd.exe /C ....static StringquoteArgument(String argument) Quotes an argument while escaping special characters interpreted by CreateProcess.static StringquoteArgumentForCmd(String argument) Quotes an argument while escaping special characters suitable for use as an argument tocmd.exe.
-
Constructor Details
-
WindowsUtil
public WindowsUtil()
-
-
Method Details
-
quoteArgument
Quotes an argument while escaping special characters interpreted by CreateProcess.- Parameters:
argument- argument to be quoted or escaped for windows shells.- Returns:
- properly quoted and escaped windows arguments.
-
quoteArgumentForCmd
Quotes an argument while escaping special characters suitable for use as an argument tocmd.exe.- Parameters:
argument- argument to be quoted or escaped forcmd.exe.- Returns:
- properly quoted and escaped arguments to
cmd.exe.
-
execCmd
Executes a command and arguments usingcmd.exe /C ....- Parameters:
argv- arguments to be quoted or escaped forcmd.exe /C ....- Returns:
- properly quoted and escaped arguments to
cmd.exe /C .... - Throws:
IOException
-
createJunction
@NonNull public static File createJunction(@NonNull File junction, @NonNull File target) throws IOException, InterruptedException Creates an NTFS junction point if supported. Similar to symbolic links, NTFS provides junction points which provide different features than symbolic links.- Parameters:
junction- NTFS junction point to createtarget- target directory to junction- Returns:
- the newly created junction point
- Throws:
IOException- if the call to mklink exits with a non-zero status codeInterruptedException- if the call to mklink is interrupted before completingUnsupportedOperationException- if this method is called on a non-Windows platform
-