我有一个批处理文件,其中包含以下代码,
move "%UserProfile%\Desktop\System" "%ProgramData%\Microsoft\Windows\Start Menu\Programs"
应该将桌面上的“系统”文件夹移动到%ProgramData%\Microsoft\Windows\Start Menu\Programs
,但它表示文件正在使用中,因此无法移动
批处理文件的代码为
@echo off
del /q /f "C:\Users\Public\Desktop\Google Chrome.lnk"
del /q /f "%USERPROFILE%\Desktop\Microsoft Edge.lnk"
del /f /s /q /a "%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\*"
REG DELETE HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband /F
taskkill /f /im explorer.exe
start explorer.exe
cd "%USERPROFILE%\Desktop"
mkdir "Accessories"
mkdir "Admin Tools"
mkdir "System"
move "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Accessories\*.lnk" "%UserProfile%\Desktop\Accessories"
move "%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\*.lnk" "%UserProfile%\Desktop\Accessories"
move "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools\*.lnk" "%UserProfile%\Desktop\Accessories"
move "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Accessibility\*.lnk" "%UserProfile%\Desktop\Accessories"
move "%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessibility\*.lnk" "%UserProfile%\Desktop\Accessories"
move "%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Windows PowerShell\*.lnk" "%UserProfile%\Desktop\System"
move "%ProgramData%\Microsoft\Windows\Start Menu\Programs\System Tools\*.lnk" "C:\Users\User\Desktop\System"
move "%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools\*.lnk" "%UserProfile%\Desktop\System"
move "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Administrative Tools\*.lnk" "%UserProfile%\Desktop\Admin Tools"
cacls "%ProgramData%\Microsoft\Windows\Start Menu\Programs" /t /e /g Administrators:f
cd "%ProgramData%\Microsoft\Windows\Start Menu\Programs"
rmdir /s /q "Accessories"
rmdir /s /q "Administrative Tools"
rmdir /s /q "Accessibility"
rmdir /s /q "System Tools"
cacls "%AppData%\Microsoft\Windows\Start Menu\Programs" /t /e /g Administrators:f
cd "%AppData%\Microsoft\Windows\Start Menu\Programs"
rmdir /s /q "Accessories"
rmdir /s /q "Administrative Tools"
rmdir /s /q "Accessibility"
rmdir /s /q "Windows PowerShell"
rmdir /s /q "System Tools"
taskkill /f /im explorer.exe
start explorer.exe
cd "%UserProfile%\Desktop\System"
ren "computer.lnk" "This PC.lnk"
move "%UserProfile%\Desktop\Accessories" "%ProgramData%\Microsoft\Windows\Start Menu\Programs"
move "%UserProfile%\Desktop\Admin Tools" "%ProgramData%\Microsoft\Windows\Start Menu\Programs"
move "%UserProfile%\Desktop\System" "%ProgramData%\Microsoft\Windows\Start Menu\Programs"
taskkill /f /im explorer.exe
start explorer.exe
pause
答案 0 :(得分:0)
CWD是您要移动的文件夹。
这些是令人反感的行
cd "%UserProfile%\Desktop\System"
move "%UserProfile%\Desktop\System" "%ProgramData%\Microsoft\Windows\Start Menu\Programs"
您已将当前工作目录(CWD)更改为%UserProfile%\Desktop\System
,然后尝试移动该目录。
某些程序可能很聪明,可以找出您想要的东西,但是cmd.exe并不是其中之一。它固有地锁定了CWD。 (我认为它还会锁定目录堆栈中的所有其他目录-PUSHD / POPD。)
首先,将CD移至其他目录,然后再尝试移动%UserProfile%\Desktop\System
。