Squashman wrote:Has nothing to do with TABS. I did use TABS and I do use N++. The forum software converts the TABS to spaces, when you paste code into the forum. I indent with tabs all day, all night, 24 hours a day, 7 days a week, 365 days a year!
I figured something like that was the case. The problem was something to do with tabs inside an if...else block but can't reproduce now. I wonder if VS can format batch.
Here's the alpha code to be uploaded.
It's tested, but not for all combos.
Major problem is that the UAC stuff at the beginning doesn't like being run out of a 7z archive.
Code: Select all
:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights (thanks to TanisDLJ at Stackoverflow)
:::::::::::::::::::::::::::::::::::::::::
@echo off
color 1E
mode 100,50
VERIFY > nul
CLS
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\icacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo args = "" >> "%temp%\getadmin.vbs"
echo For Each strArg in WScript.Arguments >> "%temp%\getadmin.vbs"
echo args = args ^& strArg ^& " " >> "%temp%\getadmin.vbs"
echo Next >> "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", args, "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs" %*
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
Setlocal EnableDelayedExpansion & CD /D "%~dp0"
::::::::::::::::::::::::::::
::START
::::::::::::::::::::::::::::
REM Run shell as admin (example) - put here code as you like
set CREATKIT=
set TESVGAME=
set TES5EDIT=
tasklist /fi "IMAGENAME eq CreationKit.exe" | find /i "CreationKit.exe" > nul
if %errorlevel% EQU 0 set CREATKIT=Creation Kit is running
tasklist /fi "IMAGENAME eq tesv.exe" | find /i "tesv.exe" > nul
if %errorlevel% EQU 0 set TESVGAME=Skyrim is running
tasklist /fi "IMAGENAME eq TES5Edit.exe" | find /i "TES5Edit.exe" > nul
if %errorlevel% EQU 0 set TES5EDIT=TES5Edit is running
echo(
echo(
If DEFINED CREATKIT echo %CREATKIT%
If DEFINED TESVGAME echo %TESVGAME%
If DEFINED TES5EDIT echo %TES5EDIT%
echo(
echo(
echo Welcome to the FNIS Remnant Removal Tool!
echo(
echo Before continuing this script, check the install status of the FNIS Creature Pack:
echo(
echo If installed, open the FNIS Generator and click "De-Install Creatures", and quit the Generator.
echo(
echo Then deactivate and uninstall FNIS, FNIS Creature Pack, and FNIS Spells through your mod manager.
echo(
:PROMPTBEGIN
SET "validateText="
SET /P validateText="________________________________Are you ready? type Y or N_________________________________Y/N]"
echo(
echo(
@echo off
if /I !validateText!==y goto BEGIN
if /I !validateText!==n goto ENDSCRIPT
GOTO PROMPTBEGIN
:BEGIN
tasklist /fi "IMAGENAME eq GenerateFNISforUsers.exe" | find /i "GenerateFNISforUsers.exe" > nul
if %errorlevel% EQU 1 goto REMOVEPROMPT
:PromptTerminate
REM Eliminate poison chars on <CR>
SET "FNISRUNNING="
echo(
SET /P FNISRUNNING="FNIS Generator is still running! Type T to terminate it or K to keep it running and cancel out.[T/K]"
@echo off
if /I !FNISRUNNING!==t goto NOFNISRUN
if /I !FNISRUNNING!==k goto ENDSCRIPT
goto PromptTerminate
:NOFNISRUN
@echo off
taskkill /im GenerateFNISforUsers.exe /f
:REMOVEPROMPT
color 1E
SET "validateText="
echo(
SET /P validateText="___________All FNIS generated remnants to be removed at this time? (no recycle bin)__________(Y/N)"
if /I !validateText!==n goto ENDSCRIPT
if /I !validateText!==y goto BEGINDELETE
goto REMOVEPROMPT
:BEGINDELETE
@echo off
echo(
echo _______________________________......Processing for %USERNAME%......__________________________________
echo(
set /A FNISDRIVE=0
REM SET "FOLDERSET=Users\New\Desktop*"
SET "FOLDERSET=F* G* R* S*"
set CURRDRIVE=B
SET SKYRIMFOLDER=
:SEARCHDRIVES
REM BLOCK
for %%B in (B C D E F G) do (
if exist %%B: (
%%B:
cd \
if NOT DEFINED SKYRIMFOLDER (
for /D %%C in (!FOLDERSET!) do (
pushd %%C
for /D /R %%G in ("*") do (
if exist "%%G\tesv.exe" (
call set "SKYRIMFOLDER=%%G"
GOTO GOTSKYRIMFOLDER
)
)
popd
)
) else (
if %CURRDRIVE%==%%B (
for /D %%C in (!FOLDERSET!) do (
pushd %%C
for /D /R %%G in ("*") do (
@echo off
if exist "%%G\tesv.exe" (
call set "SKYRIMFOLDER=%%G"
echo(
echo | set /p validateText="Skyrim files are detected on another drive."
:DRIVEPROMPT
set "validateText="
echo(
set /p "validateText=Type Y to delete FNIS remnant files there or N to quit. (Y/N)"
echo(
@echo off
if /I !validateText!==n goto FINISH
if /I !validateText!==y GOTO GOTSKYRIMFOLDER
goto DRIVEPROMPT
)
)
popd
)
)
)
REM SKYRIMFOLDER DEFINED
)
REM Exist Drive
)
REM Drives Loop
REM BLOCK
if DEFINED SKYRIMFOLDER (
IF %FNISDRIVE% EQU 0 (
GOTO ENDSCRIPT
) else (
GOTO FINISH
)
)
echo(
echo No Skyrim installed on any of the "standard" paths.
:NOSKYRIMPROMPT
SET "validateText="
echo(
SET /P validateText="Input at least the first letter of its root install path (no wildcards) or space to exit."
set FOLDERSET=%validateText:~0,1%
FOR %%G IN (a b c d e f g h i j k l m n o p q r s t u v x y z 0 1 2 3 4 5 6 7 8 9) DO (
If !FOLDERSET!==%%G (
set "FOLDERSET=!validateText!*"
set CURRDRIVE=B
SET SKYRIMFOLDER=
GOTO SEARCHDRIVES
)
)
if "!FOLDERSET!"==" " GOTO ENDSCRIPT
goto NOSKYRIMPROMPT
:GOTSKYRIMFOLDER
REM Only one occurrence of TES5.exe considered on each drive
for %%T in (%CURRDRIVE%) do (
if exist %%T: (
%%T:
cd \
for /D %%C in (!FOLDERSET!) do (
pushd %%C
for /D /R %%K in ("*") do (
Set FNISTEMP=%%K
SET _FNISFOLDERUSERS=!FNISTEMP:GenerateFNIS_for_Users=!
IF NOT !FNISTEMP!==!_FNISFOLDERUSERS! (
call SET "_FNISFOLDERUSERS=%%K"
goto FNISFOLDERUSERSFOUND
)
)
popd
)
)
)
for %%T in (%CURRDRIVE%) do (
if exist %%T: (
%%T:
cd \
for /D %%C in (!FOLDERSET!) do (
pushd %%C
for /D /R %%K in ("*") do (
Set FNISTEMP=%%K
SET _FNISFOLDERMODS=!FNISTEMP:GenerateFNIS_for_Mods=!
IF NOT !FNISTEMP!==!_FNISFOLDERMODS! (
call SET "_FNISFOLDERMODS=%%K"
goto FNISFOLDERMODSFOUND
)
)
popd
)
)
)
:PATHPROMPT
SET "validateText="
set /p "=%CURRDRIVE%" <nul
SET /P validateText=": is where Skyrim exists but FNIS isn't found on standard or input paths. Search more drives? (Y/N)"
if /I !validateText!==Y GOTO INCREMENTDRIVE
if /I !validateText!==n GOTO ENDSCRIPT
goto PATHPROMPT
REM Do the data directories match?
:FNISFOLDERUSERSFOUND
set "FNISTEMP=\temporary_logs"
REM just in case the temporary_logs folder is found
SET FNISFOLDERUSERS=!_FNISFOLDERUSERS:FNISTEMP=\!
IF !FNISFOLDERUSERS!==!_FNISFOLDERUSERS! (
SET FNISTEMP=!_FNISFOLDERUSERS!
) else (
SET FNISTEMP=!FNISFOLDERUSERS!
)
set FNISFOLDER=!FNISTEMP:\tools\GenerateFNIS_for_Users=\!
GOTO FNISCOMPARE
:FNISFOLDERMODSFOUND
set FNISTEMP=\temporary_logs
REM just in case the temporary_logs folder is found
SET FNISFOLDERMODS=!_FNISFOLDERMODS:FNISTEMP=\!
IF !FNISFOLDERMODS!==!_FNISFOLDERMODS! (
SET FNISTEMP=!_FNISFOLDERMODS!
) else (
SET FNISTEMP=!FNISFOLDERMODS!
)
set FNISFOLDER=!FNISTEMP:\tools\GenerateFNIS_for_Mods=\!
:FNISCOMPARE
IF /I NOT "!SKYRIMFOLDER!\Data\"=="!FNISFOLDER!" (SET MOINSTALLED=YES)
cd /d %CURRDRIVE%:\
cd !FNISFOLDER!
cls
echo(
echo _______________________________......Processing for %USERNAME%......__________________________________
echo(
echo(
echo(
echo(
@echo off
set "logFile=C:\Users\%USERNAME%\Documents\My Games\Skyrim\Logs\FNISREMOVE.log"
REM Recycle log if too large
set /A TESTVAL=%FNISDRIVE% * 3000
for %%a in ("%logFile%") do if %%~za gtr TESTVAL (
type nul > "%logFile%"
)
if exist "%logFile%" (set "operator=>>") else (set "operator=>")
set "log=%operator% "%logFile%""
%log% (
echo Start time is: %date% %TIME%
@echo on
SET "FNISTEMP=!FNISFOLDER!Meshes\actors\character\behaviors\0_master.hkx"
IF EXIST !FNISTEMP! (
del /F /S /Q "!FNISTEMP!"
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
SET "FNISTEMP=!FNISFOLDER!Meshes\actors\character\behaviors\mt_behavior.hkx"
IF EXIST !FNISTEMP! (
del /F /S /Q "!FNISTEMP!"
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
SET "FNISTEMP=!FNISFOLDER!Meshes\actors\character\behaviors\FNIS*.hkx"
IF EXIST !FNISTEMP! (
del /F /S /Q "!FNISTEMP!"
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
SET "FNISTEMP=!FNISFOLDER!Meshes\actors\character\characters\defaultmale.hkx"
IF EXIST !FNISTEMP! (
del /F /S /Q "!FNISTEMP!"
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
SET "FNISTEMP=!FNISFOLDER!Meshes\actors\character\characters\female\defaultfemale.hkx"
IF EXIST !FNISTEMP! (
del /F /S /Q "!FNISTEMP!"
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
SET "FNISTEMP=!FNISFOLDER!Meshes\animationsetdatasinglefile.txt"
IF EXIST !FNISTEMP! (
del /F /S /Q "!FNISTEMP!"
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
SET "FNISTEMP=!FNISFOLDER!FNISspell.esp"
IF EXIST !FNISTEMP! (
del /F /S /Q "!FNISTEMP!"
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
SET "FNISTEMP=!FNISFOLDER!Meshes\AnimObjects\FNIS"
IF EXIST !FNISTEMP! (
RD /S /Q "!FNISTEMP!"
REM RD does not echo deletion confirmation
echo "!FNISTEMP!" directory should be removed.
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
SET "FNISTEMP=!FNISFOLDER!Meshes\actors\character\animations\FNIS"
IF EXIST !FNISTEMP! (
RD /S /Q "!FNISTEMP!"
echo "!FNISTEMP!" directory should be removed.
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
SET "FNISTEMP=!FNISFOLDER!Meshes\actors\character\animations\FNISBase"
IF EXIST !FNISTEMP! (
RD /S /Q "!FNISTEMP!"
echo "!FNISTEMP!" directory should be removed.
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
SET "FNISTEMP=!FNISFOLDER!Meshes\actors\character\animations\FNISSpells"
IF EXIST !FNISTEMP! (
RD /S /Q "!FNISTEMP!"
echo "!FNISTEMP!" directory should be removed.
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
SET "FNISTEMP=!FNISFOLDER!Tools\GenerateFNIS_for_Modders"
IF EXIST !FNISTEMP! (
RD /S /Q "!FNISTEMP!"
echo "!FNISTEMP!" directory should be removed.
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
SET "FNISTEMP=!FNISFOLDER!Tools\GenerateFNIS_for_Users"
IF EXIST !FNISTEMP! (
RD /S /Q "!FNISTEMP!"
echo "!FNISTEMP!" directory should be removed.
) else (
echo "!FNISTEMP!" could not be found so not deleted.
)
REM Some problem with FNIS file deletions?
if '%errorlevel%' NEQ '0' goto ENDSCRIPT
)
@echo off
set /A FNISDRIVE=FNISDRIVE+1
:INCREMENTDRIVE
if %CURRDRIVE%==B (
set CURRDRIVE=C
GOTO SEARCHDRIVES)
if %CURRDRIVE%==C (
set CURRDRIVE=D
GOTO SEARCHDRIVES)
if %CURRDRIVE%==D (
set CURRDRIVE=E
GOTO SEARCHDRIVES)
if %CURRDRIVE%==E (
set CURRDRIVE=F
GOTO SEARCHDRIVES)
if %CURRDRIVE%==F (
set CURRDRIVE=G
GOTO SEARCHDRIVES)
:FINISH
color 1E
IF DEFINED MOINSTALLED (
echo(
echo TES Data directory contents have likely moved to a MO dir. andor there exists a backup drive.
echo(
)
echo(
IF %FNISDRIVE% EQU 1 (
echo Success: FNIS remnants removed on exactly one drive. Log opens with Notepad if no viewer associated.
) else (
echo Success: FNIS remnants removed on more than one drive. Log opens with Notepad if no viewer associated.
)
echo(
:PROMPTFINISH
SET "validateText="
SET /P validateText="Type S to delete script, L to delete log, A to delete script and log, K to keep all. (S/L/A/K)"
if /i !validateText!==S (
FOR /F "Tokens=1 delims=," %%G IN ('ASSOC .log') DO (@Set ASSOCLOG=%%G)
if DEFINED ASSOCLOG ("%LOGFILE%"
) else (start "" notepad "%LOGFILE%")
call :deleteSelf
goto :eof)
if /i !validateText!==L (
If EXIST "%logFile%" (del "%LOGFILE%" /F /S /Q)
goto :eof)
if /i !validateText!==A (
If EXIST "%logFile%" (del "%LOGFILE%" /F /S /Q)
call :deleteSelf
goto :eof)
if /i !validateText!==K (
FOR /F "Tokens=1 delims=," %%G IN ('ASSOC .log') DO (@Set ASSOCLOG=%%G)
if DEFINED ASSOCLOG ("%LOGFILE%"
) else (start "" notepad "%LOGFILE%")
goto :eof)
GOTO :PROMPTFINISH
:ENDSCRIPT
color C0
ECHO (^G)
cls
@echo off
echo(
echo(
echo(
echo Some or all of the FNIS remnant files were not removed at this time.
echo(
pause >nul
EXIT /b 0
endlocal
:deleteSelf
start /b "" cmd /c del /F /Q "%~f0"&exit /b