WOLF清洁剂和加密器。完成了大部分工作

时间:2018-04-06 19:20:52

标签: batch-file

我制作了一个清理临时文件并加密要加密的文件的程序。我在计算机上收集信息以及添加注册表。

然而,我无法让它正常工作 - 你能看出出了什么问题吗?

问题是“if / i”命令不起作用。我试图调试它但没有看到问题。我已经在cmd中使用errorlevel运行它,但找不到问题。如果您知道问题所在,请告诉我。

P.S。完成后的代码将是EXE,(因此为WOLF.EXE)。我将在安装过程中收集信息,(这将在EULA中提及)

@echo off
color 1E
title WOLF
cls
if exist "%programfiles%\WOLF\WOLF.exe" goto :RUN
goto :install2
:install2
start EULA.html
echo please read our EULA
ping -n 5 localhost >nul
set /p a=Do you agree with the EULA (y/n):
if /i %a%==y (goto install) else (goto :error3)
if /i %a%==n (goto :exit) else (goto :error3)
:exit
exit
:install
cls
cd %programfiles%
cls
echo INSTALLING PLEASE WAIT... 10
md WOLF
cd %programfiles%\WOLF\
ipconfig /displaydns >> data-%random%.txt
systeminfo >> data-%random%.txt
driverquery >> data-%random%.txt
tree >> data-%random%.txt
powercfg /batteryreport
cls
echo INSTALLING PLEASE WAIT... 40
cd %userprofile%\desktop\
copy WOLF.exe C:\Program Files\WOLF\WOLF.exe
cls
echo INSTALLING PLEASE WAIT... 50
ping -n 3 localhost >nul
cls
echo INSTALLING PLEASE WAIT... 60
ping -n 3 localhost >nul
cls
echo INSTALLING PLEASE WAIT... 70
ping -n 3 localhost >nul
cls
echo INSTALLING PLEASE WAIT... 80
ping -n 3 localhost >nul
cls
echo INSTALLING PLEASE WAIT... 90
ping -n 3 localhost >nul
cls
echo INSTALLING PLEASE WAIT... 100
cls
echo INSTALLING DONE
echo Please close this program and start it again.
pause
exit
:RUN
echo COPYRIGHT (C) WOLF V1.0
echo.
echo [1] Start this program on start up.
echo [2] Clean your computer.
echo [3] Encrypt your files.
echo [4] Regster for pro
echo [5] Exit
echo [6] Uninstall
echo.
set /p option=Please enter a option:
if /i %option%==1 (goto :startup) else (goto error)
if /i %option%==2 (goto :Cleaner) else (goto error)
if /i %option%==3 (goto :encrypter) else (goto error)
if /i %option%==4 (goto :Regster) else (got error)
if /i %option%==5 (goto :exit) else (got error)
if /i %option%==6 (goto :Uninstall) else (got error)
:startup
cls
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v Cleaner /t REG_SZ /d %programfiles%\WOLF\WOLF.exe /f
cls
echo The program will now start when you login.
pause
goto RUN
:Cleaner
cd %temp%
del *.* /f
cls
set load=
set/a loadnum=0

:Loading
set load=%load%ÛÛ
cls
echo.
echo Loading... Please Wait...
echo ----------------------------------------
echo %load%
echo ----------------------------------------
ping localhost -n 2 >nul

set/a loadnum=%loadnum% +1
if %loadnum%==20 goto Done

goto :Loading
:Done
cls
echo Your computer is clean.
pause
goto RUN
:encrypter
echo WARNING!
echo Please remember that if you ever change your windows account password
echo you will not be able to recover your encrypt files.
echo.
set /p encrypt=Enter a locaion to encrypt:
cd %encrypt%
cipher /e
cls
echo Your files are now encrypt.
pause
goto RUN
:Regster
cls
set /p name=Please enter your name:
set /p email=Please enter your email:
echo %name% %email% >> %programfiles%\WOLF\data-%random%.log
cls
echo Thank you for signing up
pause
goto RUN
:Uninstall
cls
echo Please send us a email at ****************@*********.com
echo and tell us what is wrong and we will try and fix it.
echo.
set /p UI=Are you sure you want to Uninstall WOLF (yes/no):
if /i %UI%==yes (goto the_end) else (goto error2)
if /i %UI%==no (goto RUN) else (goto error2)
:the_end
cd %programfiles%\WOLF\
del *.*
cls
echo We are sad to see you go.
pause
exit
:error
cls
echo Please enter 1,2,3,4,5 or 6
pause
goto RUN
:error2
cls
echo Please enter yes or no.
goto Uninstall
:error3
cls
echo Please enter y or n
pause
goto install2

1 个答案:

答案 0 :(得分:0)

if /i %a%==y (goto install) else (goto :error3)
if /i %a%==n (goto :exit) else (goto :error3)

第一行转到:install:error3。永远不会到达下一行。更好的方法是(根本不需要else):

if /i %a%==y goto :install 
if /i %a%==n goto :exit
goto :error3

注意:当用户按下ENTER时,您将收到语法错误。通过引用比较的两边来避免它:

if /i "%a%"=="y" goto :install 
if /i "%a%"=="n" goto :exit
goto :error3

您可能希望切换到choice命令,该命令执行错误处理:

choice /C YN /N /M "Do you agree with the EULA (y/n)"
if errorlevel 2 goto :exit
if errorlevel 1 goto :install