diff --git a/src/Microsoft.Dism/DismApi.AddDriver.cs b/src/Microsoft.Dism/DismApi.AddDriver.cs index fa1c95b..2e6020c 100644 --- a/src/Microsoft.Dism/DismApi.AddDriver.cs +++ b/src/Microsoft.Dism/DismApi.AddDriver.cs @@ -2,6 +2,7 @@ // // Licensed under the MIT license. +using System.IO; using System.Runtime.InteropServices; namespace Microsoft.Dism @@ -23,6 +24,22 @@ public static void AddDriver(DismSession session, string driverPath, bool forceU DismUtilities.ThrowIfFail(hresult, session); } + /// + /// Adds third party drivers (.inf) from the specified directory to an offline Windows® image. + /// + /// A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the method. + /// A relative or absolute path to a directory containing driver .inf files. + /// Indicates whether to accept unsigned drivers to an x64-based image. Unsigned drivers will automatically be added to an x86-based image. + /// true to search recursively for driver files, otherwise false. + /// The directory specified by the parameter does not exist. + public static void AddDriversEx(DismSession session, string driverDirectory, bool forceUnsigned, bool recursive) + { + foreach (string driverPath in Directory.EnumerateFiles(driverDirectory, "*.inf", recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)) + { + AddDriver(session, driverPath, forceUnsigned); + } + } + internal static partial class NativeMethods { ///