Package hudson.os
Class WindowsUtil
- java.lang.Object
-
- hudson.os.WindowsUtil
-
public class WindowsUtil extends Object
Utilities for the Windows Platform. Adapted from: Everyone quotes command line arguments the wrong way- Since:
- 2.183
-
-
Constructor Summary
Constructors Constructor Description WindowsUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FilecreateJunction(File junction, File target)Creates an NTFS junction point if supported.static ProcessexecCmd(String... argv)Executes 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.
-
-
-
Method Detail
-
quoteArgument
@NonNull public static String quoteArgument(@NonNull String argument)
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
@NonNull public static String quoteArgumentForCmd(@NonNull String argument)
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
@NonNull public static Process execCmd(String... argv) throws IOException
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
-
-