我的批处理文件是否与所有计算机兼容?

时间:2014-09-28 20:09:21

标签: batch-file

这适用于Windows 8并始终有效吗?我在Windows 7上测试了它,但我不确定...我有一个朋友测试它,他说它找不到正确的路径但我查了一下,命令的语法是一样的我不喜欢不知道为什么会有问题。假设%USERPROFILE%\ Documents \ My Games \ Terraria \ Players和%USERPROFILE%\ Google Drive已经存在

@echo off
echo Administrative permissions required. Detecting permissions...

net session >nul 2>&1
if %errorLevel% == 0 (
echo Success: Administrative permissions confirmed.
) else (
echo Failure: Current permissions inadequate. Please run as administatior.
pause >nul
exit
)

echo ---------------------------------------------
echo Below enter "S" for simple install type or "A" for avanced install type.
echo (Simple is recommended, only use advanced if you know what your doing!)
echo ---------------------------------------------

set /p option=Enter:
if /i "%option%"=="S" goto simple
if /i "%option%"=="A" goto advanced


echo Your entry did not match available options. Try again.
pause >nul
exit 

:simple
mklink /d "%USERPROFILE%\Google Drive\Terraria" "%USERPROFILE%\Documents\My Games\Terraria\Players"

cd %USERPROFILE%\Google Drive\Terraria\
copy /y NUL marker >nul
cd %USERPROFILE%\Documents\My Games\Terraria\Players

if exist marker (
    echo Validation of installation complete. Symbolic link functional.
    del marker
) else (
    echo SOMETHING WENT WRONG!!!!!!!!
)

echo ==============
echo You Selected Simple.  & echo.If there are no errors above, your installation should be complete.
echo ==============
pause >nul
exit

:advanced
mkdir "%USERPROFILE%\Google Drive\Terraria"
mklink /d "%USERPROFILE%\Google Drive\Terraria\Players" "%USERPROFILE%\Documents\My Games\Terraria\Players"

cd %USERPROFILE%\Google Drive\Terraria\Players 
copy /y NUL marker >nul
cd %USERPROFILE%\Documents\My Games\Terraria\Players

if exist marker (
    echo Validation of installation complete. Symbolic link functional.
    del marker >nul
) else (
    echo SOMETHING WENT WRONG!!!!!!!!
)

echo ==============
echo You Selected Advanced.  & echo.If there are no errors above, your installation should be complete.
echo ==============
pause >nul
exit

1 个答案:

答案 0 :(得分:0)

如果交付所有路径都存在......

在Vista中引入了

mklink命令,因此该脚本无法在XP / 2003上运行。