各位好:
我目前想要弄一個可以自己判斷系統OS之後將某個捷徑複製到該系統的啟動區的批次檔
判斷OS部分已經可以了
捷徑區的路徑我可以用指令找到一部分
例如:SET USERPROFILE 我可以找到 USERPROFILE=C:\Users\myuser
不過我不知道如何在加上\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup (w7啟動區路徑) ,並且使用xcopy複製到這邊..
請問有人有任何經驗嗎?
感謝!
下面是我目前的批次:
@echo OFF
Wmic OS Get Caption | Find /i "Windows XP" >nul && goto xp
Wmic OS Get Caption | Find /i "Windows 7" >nul && goto w7
Wmic OS Get Caption | Find /i "Windows 10" >nul && goto w10
pause >null
: xp
(set|find "PROCESSOR_ARCHITECTURE")|find "32" >nul && goto xp32
(set|find "PROCESSOR_ARCHITECTURE")|find "64" >nul && goto xp64
: w7
(set|find "PROCESSOR_ARCHITECTURE")|find "32" >nul && goto w732
(set|find "PROCESSOR_ARCHITECTURE")|find "64" >nul && goto w764
: w10
(set|find "PROCESSOR_ARCHITECTURE")|find "32" >nul && goto w1032
(set|find "PROCESSOR_ARCHITECTURE")|find "64" >nul && goto w1064
:xp32
echo xp_32 command
goto exit
:xp64
echo xp_64 command
goto exit
:w732
echo w7_32 command
goto exit
:w764
echo w7_64 command
goto exit
:w1032
echo w10_32 command
goto exit
:w1064
echo w10_64 command
goto exit
exit
pause
appdata 是跟著 user profile 執行的。
所以要注意一定是user登入之後,以該user身份執行。
你可以這樣做
xcopy <source> %AppData%\<new path>
相關特殊路徑
%AllUsersProfile% - Open the All User's Profile C:\ProgramData
%AppData% - Opens AppData folder C:\Users{username}\AppData\Roaming
%CommonProgramFiles% - C:\Program Files\Common Files
%CommonProgramFiles(x86)% - C:\Program Files (x86)\Common Files
%HomeDrive% - Opens your home drive C:
%LocalAppData% - Opens local AppData folder C:\Users{username}\AppData\Local
%ProgramData% - C:\ProgramData
%ProgramFiles% - C:\Program Files or C:\Program Files (x86)
%ProgramFiles(x86)% - C:\Program Files (x86)
%Public% - C:\Users\Public
%SystemDrive% - C:
%SystemRoot% - Opens Windows folder C:\Windows
%Temp% - Opens temporary file Folder C:\Users{Username}\AppData\Local\Temp %UserProfile% - Opens your user's profile C:\Users{username}