forked from StarCoreSE/Orrery-Combat-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec85e2a
commit d6a9d9a
Showing
1 changed file
with
56 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,71 @@ | ||
@echo off | ||
setlocal enabledelayedexpansion | ||
|
||
:: Check if the script is running with administrative privileges | ||
NET SESSION >NUL 2>&1 | ||
if %ERRORLEVEL% NEQ 0 ( | ||
echo Please run this script as administrator! | ||
REM Check if the script is running as administrator | ||
>nul 2>&1 "%SystemRoot%\system32\cacls.exe" "%SystemRoot%\system32\config\system" | ||
if '%errorlevel%' NEQ '0' ( | ||
echo. | ||
echo ==================================================== | ||
echo This script must be run as an administrator to remove symlinks! | ||
echo Right-click the script and select "Run as administrator". | ||
echo ==================================================== | ||
echo. | ||
pause | ||
exit /b 1 | ||
exit /b | ||
) | ||
|
||
set "targetDir=%APPDATA%\SpaceEngineers\Mods" | ||
set "desktopDir=%USERPROFILE%\Desktop\SpaceEngineersModsBackup" | ||
REM Define the root Space Engineers mod directory | ||
set modRootDir="%APPDATA%\SpaceEngineers\Mods" | ||
|
||
:: Creating desktop directory if it doesn't exist | ||
if not exist "%desktopDir%" ( | ||
mkdir "%desktopDir%" | ||
REM Check if the mod directory exists | ||
if not exist !modRootDir! ( | ||
echo Mod directory does not exist: !modRootDir! | ||
echo Please ensure that the Space Engineers game has created mod directories. | ||
pause | ||
exit /b | ||
) | ||
|
||
:: Copying non-symbolic link folders to the desktop | ||
for /d %%i in ("%targetDir%\*") do ( | ||
set "folderName=%%~nxi" | ||
fsutil reparsepoint query "%%i" > nul 2>&1 | ||
if errorlevel 1 ( | ||
robocopy "%%i" "%desktopDir%\!folderName!" /E /NFL /NDL /NJH /NJS /nc /ns /np | ||
) | ||
REM Change to the mod directory | ||
cd /d "!modRootDir!" | ||
|
||
REM List only symbolic links in the mod directory | ||
echo. | ||
echo Searching for symbolic links in: !modRootDir! | ||
set foundSymlink=false | ||
for /f "tokens=*" %%l in ('dir /AL /B') do ( | ||
set foundSymlink=true | ||
echo Found symlink: %%l | ||
) | ||
|
||
REM Check if any symbolic links were found | ||
if "!foundSymlink!"=="false" ( | ||
echo No symbolic links found in: !modRootDir! | ||
pause | ||
exit /b | ||
) | ||
|
||
REM Prompt the user for confirmation once to delete all symbolic links | ||
set /p confirmDelete="Do you want to delete all symlinks in this directory? [Y/N]: " | ||
if /i "!confirmDelete!" NEQ "Y" ( | ||
echo Operation canceled. No symlinks were removed. | ||
pause | ||
exit /b | ||
) | ||
|
||
:: Removing symbolic links from the mod folder | ||
for /d %%i in ("%targetDir%\*") do ( | ||
set "folderName=%%~nxi" | ||
fsutil reparsepoint query "%%i" > nul 2>&1 | ||
if not errorlevel 1 ( | ||
rmdir /s /q "%%i" | ||
echo Removed symlink in "%%i" | ||
REM Remove all symlinks in the mod directory | ||
echo. | ||
echo Deleting all symbolic links in: !modRootDir! | ||
for /f "tokens=*" %%l in ('dir /AL /B') do ( | ||
echo Removing symlink: %%l | ||
rmdir "%%l" | ||
if !errorlevel! == 0 ( | ||
echo Successfully removed symlink: %%l | ||
) else ( | ||
echo Failed to remove symlink: %%l. Check permissions or path issues. | ||
) | ||
) | ||
|
||
REM Completion message | ||
echo. | ||
echo All symbolic links have been removed from: !modRootDir! | ||
pause |