{"record":{"id":"1293d8e06a2dc9b8","repo":"peass-ng/PEASS-ng","slug":"moveoptions-delayuntilreboot-is-not-allowed-when-u","errorCode":null,"errorMessage":"MoveOptions.DelayUntilReboot is not allowed when using a network path.","messagePattern":"MoveOptions\\.DelayUntilReboot is not allowed when using a network path\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File CopyMove/File.VerifyDelayUntilReboot.cs","lineNumber":43,"sourceCode":"namespace 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":25,"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#L25-L50","documentation":"Windows MOVEFILE_DELAY_UNTIL_REBOOT operations are processed before the network stack is available, so the source file cannot reside on a UNC/network share. AlphaFS checks Path.IsUncPathCore and throws ArgumentException(\"moveOptions\") when DelayUntilReboot is combined with a network path.","triggerScenarios":"Calling File.Move / CopyMove with MoveOptions.DelayUntilReboot where sourcePath starts with \\\\server\\share (or \\\\?\\UNC\\...).","commonSituations":"Deploy scripts or cleanup jobs that defer moves of files stored on network shares; moving logs/artifacts from a mapped-share location with DelayUntilReboot set.","solutions":["Copy the file from the share to a local path first, then schedule the delayed move on the local file.","Remove MoveOptions.DelayUntilReboot and perform the network move immediately (handle sharing violations with CopyAllowed/retry instead).","Point the operation at a local drive path if a delayed move is mandatory."],"exampleFix":"// before\nFile.Move(@\"\\\\server\\share\\app.dll\", @\"C:\\app\\app.dll\", MoveOptions.DelayUntilReboot); // ArgumentException\n// after\nFile.Copy(@\"\\\\server\\share\\app.dll\", @\"C:\\app\\app.dll.new\", true);\nFile.Move(@\"C:\\app\\app.dll.new\", @\"C:\\app\\app.dll\", MoveOptions.DelayUntilReboot);","handlingStrategy":"validation","validationCode":"if (moveOptions.HasFlag(MoveOptions.DelayUntilReboot) && (sourcePath.StartsWith(@\"\\\\\", StringComparison.Ordinal)))\n    throw new ArgumentException(\"DelayUntilReboot is not supported for UNC/network paths.\");","typeGuard":"static bool IsUncPath(string p) => p != null && p.StartsWith(@\"\\\\\", StringComparison.Ordinal);","tryCatchPattern":"try { File.Move(src, dst, MoveOptions.DelayUntilReboot); }\ncatch (ArgumentException ex) when (ex.ParamName == \"moveOptions\" && ex.Message.Contains(\"network\"))\n{\n    // copy locally first, then schedule the delayed move on the local copy\n    var local = Path.Combine(Path.GetTempPath(), Path.GetFileName(src));\n    File.Copy(src, local, true);\n    File.Move(local, dst, MoveOptions.DelayUntilReboot);\n}","preventionTips":["Restrict DelayUntilReboot moves to local drive paths","Resolve mapped drives to their UNC form and detect it before scheduling delayed moves","Copy from shares to local storage first, then defer the final swap until reboot"],"tags":["network","unc","move-options","argumentexception"],"backgroundTag":"delayed-move-network-path","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}