forked from StarCoreSE/Orrery-Combat-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove-semods-symlinks.bat
71 lines (62 loc) · 1.96 KB
/
remove-semods-symlinks.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@echo off
setlocal enabledelayedexpansion
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
)
REM Define the root Space Engineers mod directory
set modRootDir="%APPDATA%\SpaceEngineers\Mods"
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
)
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
)
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