{"record":{"id":"635ffaadd4f3ed77","repo":"peass-ng/PEASS-ng","slug":"moveoptions-copyallowed-is-not-allowed-when-using","errorCode":null,"errorMessage":"MoveOptions.CopyAllowed is not allowed when using the MoveOptions.DelayUntilReboot flag.","messagePattern":"MoveOptions\\.CopyAllowed is not allowed when using the MoveOptions\\.DelayUntilReboot flag\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File CopyMove/File.VerifyDelayUntilReboot.cs","lineNumber":36,"sourceCode":" *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \n *  THE SOFTWARE. \n */\n\nusing System;\nusing winPEAS._3rdParty.AlphaFS;\n\nnamespace Alphaleonis.Win32.Filesystem\n{\n   public static partial class File\n   {\n      private static bool VerifyDelayUntilReboot(string sourcePath, MoveOptions? moveOptions, PathFormat pathFormat)\n      {\n         var delayUntilReboot = HasDelayUntilReboot(moveOptions);\n\n         if (delayUntilReboot)\n         {\n            if (HasCopyAllowed(moveOptions))\n               throw new ArgumentException(Resources.MoveOptionsDelayUntilReboot_Not_Allowed_With_MoveOptionsCopyAllowed, \"moveOptions\");\n\n\n            // MoveFileXxx: (lpExistingFileName) If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT,\n            // the file cannot exist on a remote share, because delayed operations are performed before the network is available.\n\n            if (Path.IsUncPathCore(sourcePath, pathFormat != PathFormat.LongFullPath, false))\n               throw new ArgumentException(Resources.MoveOptionsDelayUntilReboot_Not_Allowed_With_NetworkPath, \"moveOptions\");\n         }\n\n         return delayUntilReboot;\n      }\n   }\n}\n","sourceCodeStart":18,"sourceCodeEnd":50,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File CopyMove/File.VerifyDelayUntilReboot.cs#L18-L50","documentation":"MoveOptions.DelayUntilReboot (MOVEFILE_DELAY_UNTIL_REBOOT) cannot be combined with MoveOptions.CopyAllowed: a delayed reboot operation is registered with the session manager and cannot perform a copy fallback. VerifyDelayUntilReboot throws ArgumentException(\"moveOptions\") when both flags are present.","triggerScenarios":"Calling File.Move / CopyMove with MoveOptions such as MoveOptions.CopyAllowed | MoveOptions.DelayUntilReboot.","commonSituations":"OR-ing MoveOptions flags together to get 'maximum flexibility'; copying flag combinations from code paths that used CopyAllowed alone and adding DelayUntilReboot for offline scenarios.","solutions":["Remove MoveOptions.CopyAllowed when using MoveOptions.DelayUntilReboot.","If a copy fallback is required, drop DelayUntilReboot and perform the move immediately.","Split the logic: attempt a normal move with CopyAllowed, and only schedule DelayUntilReboot moves for locked-file cases without CopyAllowed."],"exampleFix":"// before\nvar opts = MoveOptions.CopyAllowed | MoveOptions.DelayUntilReboot; // ArgumentException\nFile.Move(src, dst, opts);\n// after\nFile.Move(src, dst, MoveOptions.DelayUntilReboot);","handlingStrategy":"validation","validationCode":"static void ValidateMoveOptions(MoveOptions opts)\n{\n    if (opts.HasFlag(MoveOptions.DelayUntilReboot) && opts.HasFlag(MoveOptions.CopyAllowed))\n        throw new ArgumentException(\"MoveOptions.CopyAllowed cannot be combined with MoveOptions.DelayUntilReboot.\");\n}","typeGuard":"static bool HasIncompatibleMoveFlags(MoveOptions opts) =>\n    opts.HasFlag(MoveOptions.DelayUntilReboot) && opts.HasFlag(MoveOptions.CopyAllowed);","tryCatchPattern":"try { File.Move(src, dst, moveOptions); }\ncatch (ArgumentException ex) when (ex.ParamName == \"moveOptions\")\n{\n    // retry without the forbidden combination\n    File.Move(src, dst, moveOptions & ~MoveOptions.CopyAllowed);\n}","preventionTips":["Never OR MoveOptions.CopyAllowed with MoveOptions.DelayUntilReboot","Centralize MoveOptions construction in one validated helper","Document flag compatibility when building option enumerations"],"tags":["arguments","move-options","argumentexception"],"backgroundTag":"incompatible-move-options","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}