Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- doskey /listsize=0
- color A
- REM -- Prepare the Command Processor
- SETLOCAL ENABLEEXTENSIONS
- SETLOCAL ENABLEDELAYEDEXPANSION
- REM -- Version History --DOS Batch - File Examples http://www.dostips.com/DtCodeBatchFiles.php
- ::: -- Version History
- ::: XX.XXX YYYYMMDD Author Description
- SET "Version=01.000-beta" &:2020 12 24 D.M. initial version, providing the framework, Please e-mail me if you are using or modifying this software. I take no credit for the individual code sections used. Most of it was found online in many different forums. The only credit I take is for the way that this scrips have been setup to work as one.
- SET "Version=01.001-beta" &:2020 12 28 D.M. Description: only provide a way of creating a .LOG file but with the benefits of having a logging user name and password, time and date stamp, and also hides the .LOG file by default. You most go to the setup section to change default user name and user password, .LOG file destination and file name are optional. Just hide this .bat file in a secrete folder location.
- SET "Version=01.002-beta" &:2021 01 04 D.M. this version fixes some miner spelling and adds a small loading screen (for looks only) and an about section.
- SET "Version=01.003-beta" &:2021 01 014 D.M. this version fixes a problem with the user name not keeping count of error tries.
- ::: !! For a new version entry, copy the last entry down and modify Date, Author and Description
- For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%a/%%b/%%c)
- For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a:%%b)
- ::echo %mydate% %mytime%
- set v_day=
- set v_month=
- set v_year=
- SETLOCAL ENABLEEXTENSIONS
- if "%date%A" LSS "A" (set toks=1-3) else (set toks=2-4)
- ::DEBUG echo toks=%toks%
- for /f "tokens=2-4 delims=(-)" %%a in ('echo:^|date') do (
- ::DEBUG echo first token=%%a
- if "%%a" GEQ "A" (
- for /f "tokens=%toks% delims=.-/ " %%i in ('date/t') do (
- set '%%a'=%%i
- set '%%b'=%%j
- set 'yy'=%%k
- )
- )
- )
- if %'yy'% LSS 100 set 'yy'=20%'yy'%
- set Today=%'yy'%-%'mm'%-%'dd'%
- ENDLOCAL & SET v_year=%'yy'%& SET v_month=%'mm'%& SET v_day=%'dd'%
- ::ECHO Today is Year: [%V_Year%] Month: [%V_Month%] Day: [%V_Day%]
- set datestring=%V_Month%/%V_Day%/%V_Year%
- ::echo %datestring%
- :EOF
- SETLOCAL ENABLEEXTENSIONS
- for /f "tokens=1-4 delims=:,.-/ " %%i in ('echo %time%') do (
- set 'hh'=%%i
- set 'mm'=%%j
- set 'ss'=%%k
- set 'ff'=%%l)
- ENDLOCAL & SET v_Hour=%'hh'%& SET v_Minute=%'mm'%& SET v_Second=%'ss'%& SET v_Fraction=%'ff'%
- ::ECHO Now is Hour: [%V_Hour%] Minute: [%V_Minute%] Second: [%v_Second%] Fraction: [%v_Fraction%]
- set timestring=%V_Hour%%V_Minute%%v_Second%.%v_Fraction%
- ::echo %timestring%
- :EOF
- cls
- ::: -- Set the window TITLE --
- SET "TITLE= %~nx0 Version %Version%"
- :create
- ::::::::::::::::::::::::::::::::::::::::::::::::
- ::::::::::::: SETUP::SETUP::SETUP:::::::::::::::
- ::::::::::::::start::start::start:::::::::::::::
- ::::::::::::::::::::::::::::::::::::::::::::::::
- REM this section sets the file destination, name, extension also the preferred text editor
- REM it is currently set to work and save directory as this bat file also the LOG file is invisible by default
- REM Example directory( %SystemDrive%\Users\%USERNAME%\Desktop\ )
- set loc=%~dp0
- ::LOG File Extension
- set ext=.LOG
- ::LOG File Name
- set logname=mylogsystem
- REM set the preferred text editor
- set editor=notepad.exe
- REM this sets your user password on CMD (its case sensitive)
- set pass=PASSWORD
- REM this sets your user name on CMD (its case sensitive)
- set name=USERNAME
- :::::::::::::::::
- REM DO NOT EDIT
- set filename=%loc%%logname%%ext%
- REM this set the LOG file invisible by default.
- ::::::::::::::::::::::::::::::::::::::::::::::::
- ::::::::::::: SETUP::SETUP::SETUP:::::::::::::::
- :::::::::::::::END::::END::::END::::::::::::::::
- ::::::::::::::::::::::::::::::::::::::::::::::::
- Title Enter Your Name %Title%
- :name
- set ntries=4
- :1top
- cls
- echo.
- call :c 07 "Please enter username to proceed " /n
- echo (do not use spaces)
- echo.
- set /a ntries=%ntries% -1
- if %ntries%==0 (
- goto penalty
- )
- echo ------------------------------------
- call :c 04 "You have "
- call :c 0b "%ntries% "
- call :c 07 "attempts left." /n
- echo ------------------------------------
- echo.
- echo.
- doskey /listsize=0
- set /p "uname= User Name:"
- if %uname%==%name% (
- cls
- ping localhost -n 3 >nul
- cls
- doskey /listsize=0
- goto psw
- ) else (
- doskey /listsize=0
- goto 1top
- )
- :afk
- Title Away from Screen %Title%
- set atries=4
- :2top
- cls
- echo.
- call :c 07 "Enter Password to Proceed " /n
- echo.
- set /a atries=%atries% -1
- if %atries%==0 (
- goto penalty
- )
- echo ------------------------------------
- call :c 04 "You have "
- call :c 0b "%atries% "
- call :c 07 "attempts left." /n
- echo ------------------------------------
- echo.
- echo.
- set /p "password= User Password:"
- if %password%==%pass% (
- cls
- ping localhost -n 3 >nul
- cls
- doskey /listsize=0
- goto find
- ) else (
- doskey /listsize=0
- goto 2top
- )
- REM you most set the password befor hand
- :psw
- :: By http://www.instructables.com/member/Necrohero/
- Title Enter Your Password
- set ptries=4
- :top
- cls
- echo.
- call :c 07 "Please enter Password" /n
- echo.
- set /a ptries=%ptries% -1
- if %ptries%==0 (
- goto penalty
- )
- echo ------------------------------------
- call :c 0b " %name%, "
- call :c 04 "You have "
- call :c 0b "%ptries% "
- call :c 07 "attempts left." /n
- echo ------------------------------------
- echo.
- echo.
- doskey /listsize=0
- set /p "password= User Password:"
- if %password%==%pass% (
- cls
- echo ###########
- call :c 07 " CONNECTED! " /n
- echo ###########
- echo.
- call :c 0b "Welcome, "
- call :c 09 "%name%"
- call :c 07 "@"
- call :c 0d "%ComputerName% " /n
- echo.
- echo.
- ping localhost -n 3 >nul
- cls
- doskey /listsize=0
- goto find
- ) else (
- doskey /listsize=0
- goto top
- )
- :penalty
- Title Invalid Username or password!
- color c
- cls
- ping localhost -n 2 >nul
- cls
- ping localhost -n 2 >nul
- cls
- ping localhost -n 2 >nul
- cls
- ping localhost -n 2 >nul
- cls
- ping localhost -n 2 >nul
- cls
- setlocal EnableDelayedExpansion
- set message=Ah Ah Ah, You Didn't Say The Magic Word...
- set messageLength=44
- for /L %%J in (1,1,%messageLength%) do (
- echo !message:~0,%%J!
- ping localhost -n 1 >nul
- cls
- )
- ping localhost -n 2 >nul
- cls
- echo ------------------------------------
- call :c 0f " Please Try Agian " /n
- echo ------------------------------------
- pause > nul
- goto exit
- :find
- cls
- title Checking for %logname%%ext%
- echo.
- echo ------------------------------------
- call :c 0b " %name%, "
- call :c 0d "Checking if "
- call :c 0c "%logname%%ext% "
- call :c 0d "file exist." /n
- echo ------------------------------------
- ping localhost -n 3 >nul
- echo.
- if exist %filename% (
- goto confirm
- ) else (
- echo ------------------------------------
- call :c 07 " File"
- call :c 0c " %logname%%ext% "
- call :c 04 "doesn't exist" /n
- echo ------------------------------------
- echo.
- call :c 0e "Press any key to start a new LOG " /n
- echo.
- pause >nul
- goto EULA
- )
- :confirm
- title Loading...
- cls
- attrib "%filename%" +s +h
- echo.
- rem You can set the number of ()'s as whatever you
- rem want but remember: in your "loading box" you
- rem need 2 spaces for every () because "()" takes up
- rem 2 spaces. The above box has 40 spaces, so
- rem twenty repeats, adding 1 () every repeat.
- rem https://www.instructables.com/Loading-effect-in-batch/#step1
- set load=
- set/a loadnum=0
- :Loading
- set load=%load%/
- cls
- echo.
- echo %name%, Loading file %logname%%ext%
- echo.
- echo. ========================================
- echo. %load%
- echo. ========================================
- echo Please Wait...
- echo.
- ping localhost -n 1>nul
- set/a loadnum=%loadnum% +1
- if %loadnum%==40 goto Done
- goto Loading
- :Done
- cls
- echo.
- echo.
- echo -------------------------------------------------
- echo Done
- echo -------------------------------------------------
- echo.
- echo #
- echo #
- echo # # Loading Successfully
- echo # #
- echo #
- echo.
- echo.
- echo -------------------------------------------------
- ping -n 5 127.0.0.1 >nul
- echo.>>%filename%
- echo %mydate% %mytime%>>%filename%
- echo %name% Has logged in.>>%filename%
- echo.>>%filename%
- goto start
- :name2
- Title Change User Name %Title%
- cls
- echo.
- call :c 09 "%name%, "
- call :c 07 "Type your New Name "
- call :c 0d "(do not use spaces)" /n
- echo.
- echo.
- :sellect4
- echo.
- set /p C=%name%:
- SET name=%C%
- cls
- echo.
- echo.>>%filename%
- echo.
- call :c 09 "%name%, "
- call :c 07 "Type your old Name "
- call :c 0d "(do not use spaces) "
- call :c 07 "to indicate who you are going to be known as." /n
- echo.
- set /p old=Old Name:%old%
- echo.
- echo %mydate% %mytime%>>%filename%
- echo %old% logged out>>%filename%
- echo.>>%filename%
- echo %mydate% %mytime%>>%filename%
- echo New User %name% Logged in>>%filename%
- goto psw
- :help
- cls
- Title Help
- echo.
- echo Here are other commands that can be used!
- echo.
- Echo Type any of these
- Echo [ /clear /nick /log /age /edit /about /afk /exit]
- Echo commands to make changes to your LOG.
- echo.
- Echo Use /clear to delete LOG.
- echo.
- Echo Use /nick to change your name.
- echo.
- Echo Use /age to see if %~nx0 was tamperd with.
- Echo.
- Echo Use /edit to open LOG fiel in text editor.
- Echo.
- echo Use /about for small intro
- echo.
- echo Use /afk you most re-enter your password.
- echo.
- echo Use /exit to quit program
- echo.
- Echo Press any key to return to LOG....
- pause >nul
- goto log
- :about
- cls
- TITLE MyLog %title% %Version%
- echo.
- call :c 0a " %TITLE%" /n
- call :c 0b " Danny Muniz" /n
- call :c 0e " dannym2785@gmail.com " /n
- call :c 0c " (C) Copyright 2020 - %V_Year%" /n
- call :c 0e " All rights reserved" /n
- ECHO.
- echo.
- call :c 0e " Description" /n
- call :c 0e " -----------" /n
- echo.
- call :c 0b " %name%, "
- call :c 0e "( "
- call :c 02 "%~nx0"
- call :c 0e " ) "
- call :c 0f "My Personal Log File"
- call :c 0e " ( "
- call :c 0c "%ComputerName%"
- call :c 0e " )" /n
- ECHO.
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: Do Not deleted
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- echo.
- call :c 0c " License Agreement" /n
- call :c 0c " ------------------" /n
- echo.
- ECHO This software is distributed free of charge. It may be used as many times as you^
- like, for as long as you like, in a domestic or corporate environment. You may^
- copy and distribute copies of this program provided that you keep all original^
- documentation including this License Agreement with copyright notice and^
- disclaimer of warranty intact. You may not charge money or fees for the software^
- product to anyone.
- ECHO.
- echo.
- call :c 0c " Warranty" /n
- call :c 0c " -----------" /n
- echo.
- ECHO This program is provided "as is" without warranties of any kind, either^
- expressed or implied, including, but not limited to, the implied warranties of^
- merchantability and fitness for a particular purpose. The entire risk as to the^
- quality and performance of the program is with you. Should the program prove^
- defective, you assume the cost of all necessary servicing, repair or correction.^
- In no event will any copyright holder be liable to you for damages, including^
- any general, special, incidental or consequential damages arising out of the use^
- or inability to use the program (including but not limited to loss of data or^
- data being rendered inaccurate or losses sustained by you or third parties or a^
- failure of the program to operate with any other programs).
- echo.
- echo.
- echo.
- call :c 0f " Press Any Key To Return" /n
- pause >nul
- cls
- goto log
- :EULA
- cls
- echo.
- TITLE MyLog %title% %Version%
- echo.
- call :c 0a " %TITLE%" /n
- call :c 0b " Danny Muniz" /n
- call :c 0e " dannym2785@gmail.com " /n
- call :c 0c " (C) Copyright 2020 - %V_Year%" /n
- call :c 0e " All rights reserved" /n
- ECHO.
- echo.
- call :c 0e " Description" /n
- call :c 0e " -----------" /n
- echo.
- call :c 0b " %name%, "
- call :c 0e "( "
- call :c 02 "%~nx0"
- call :c 0e " ) "
- call :c 0f "My Personal Log File"
- call :c 0e " ( "
- call :c 0c "%ComputerName%"
- call :c 0e " )" /n
- ECHO.
- ping -n 5 127.0.0.1 >nul
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: Do Not deleted
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- echo.
- call :c 0c " License Agreement" /n
- call :c 0c " ------------------" /n
- echo.
- ECHO This software is distributed free of charge. It may be used as many times as you^
- like, for as long as you like, in a domestic or corporate environment. You may^
- copy and distribute copies of this program provided that you keep all original^
- documentation including this License Agreement with copyright notice and^
- disclaimer of warranty intact. You may not charge money or fees for the software^
- product to anyone.
- ECHO.
- echo.
- call :c 0c " Warranty" /n
- call :c 0c " -----------" /n
- echo.
- ECHO This program is provided "as is" without warranties of any kind, either^
- expressed or implied, including, but not limited to, the implied warranties of^
- merchantability and fitness for a particular purpose. The entire risk as to the^
- quality and performance of the program is with you. Should the program prove^
- defective, you assume the cost of all necessary servicing, repair or correction.^
- In no event will any copyright holder be liable to you for damages, including^
- any general, special, incidental or consequential damages arising out of the use^
- or inability to use the program (including but not limited to loss of data or^
- data being rendered inaccurate or losses sustained by you or third parties or a^
- failure of the program to operate with any other programs).
- echo.
- echo.
- call :c 0e " Important NOTE: " /n
- call :c 0e " ---------------" /n
- echo Make sure to setup your password and username within this file.
- echo.
- echo.
- call :c 0a " [1]- Yes" /n
- call :c 0c " [2]- No" /n
- echo.
- doskey /listsize=0
- set /p C=Do you agree?:
- cls
- if "%C%"=="1" goto first
- if "%C%"=="2" goto exit
- cls
- goto EULA
- :first
- cls
- echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::>>%filename%
- echo %title% %filename% >>%filename%
- echo created by (%Name%@%ComputerName%) %mytime% %mydate%>>%filename%
- echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::>>%filename%
- cls
- goto find
- ::::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- :start
- :log
- cls
- For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%a/%%b/%%c)
- For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a:%%b)
- Title %title%
- type %filename%
- echo.
- ECHO.
- echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: This tells how big is the LOG file. thanks to DosTips.com
- for %%A in (%filename%) do ECHO ::: Log File Size [ %logname%%ext% ] is [ %%~zA ] Bytes
- echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- call :c 0e " ::: Enter Your Memo Text "
- call :c 0A " :::"
- call :c 0d " For Help type /help" /n
- echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- echo.
- echo.
- doskey /listsize=0
- set /p C=%name%:
- echo.>>%filename%
- echo %mydate% %mytime%>>%filename%
- echo %name%: %C% >>%filename%
- echo.>>%filename%
- if "%C%"=="/clear" goto del
- if "%C%"=="/nick" goto name2
- if "%C%"=="/help" goto help
- if "%C%"=="/age" goto age
- if "%C%"=="/edit" goto edit
- if "%C%"=="/hide" goto secret
- if "%C%"=="/unhide" goto nosecret
- if "%C%"=="/about" goto about
- if "%C%"=="/afk" goto afk
- if "%C%"=="/exit" goto exit
- cls
- goto log
- :del
- cls
- Title Warning!! %Title%
- echo ##############
- Echo #-Warning!!!!! -#
- echo ##############
- echo.
- Echo You are about to Delete %filename%
- echo.
- echo A new %filename% file will be automaticly created.
- echo.
- echo [1]-Yes
- echo [2]-No
- :sellect6
- set /p C=Sellection:
- doskey /listsize=0
- if "%C%"=="1" goto del2
- if "%C%"=="2" goto log
- :: this will the delete the log on command
- :del2
- attrib "%filename%" -s -h
- del %filename%
- :: this tells who deleted the log
- :chat4
- For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%a/%%b/%%c)
- For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a:%%b)
- echo.>>%filename%
- echo [%mydate% %mytime%] %name% has deleted the LOG file [ %filename% ] >>%filename%
- echo.>>%filename%
- attrib "%filename%" +s +h
- cls
- goto EULA
- :nosecret
- echo %mydate% %mytime%>>%filename%
- echo %name% has unhidden the LOG file [ %filename% ]>>%filename%
- attrib "%filename%" -s -h
- ping -n 2 127.0.0.1 >nul
- cls
- goto log
- :secret
- echo %mydate% %mytime%>>%filename%
- echo %name% has hidden the LOG file [ %filename% ]>>%filename%
- attrib "%filename%" +s +h
- ping -n 2 127.0.0.1 >nul
- cls
- goto log
- :: this section tells you how long ago the batch fiel was modifide. thanks to DosTips.com
- :age
- cls
- echo.
- echo This is just a way to seen if %~nx0 was tamperd with.
- echo.
- echo.
- cd /d "%loc%"
- call:jdate tnow "%date%"
- for %%F in (%~nx0) do (
- call:ftime tfile "%%F"
- set /a diff=tnow-tfile
- cls
- echo.This program [ %%~nxF ] Was last modifide [ !diff! ] days ago.
- echo.>>%filename%
- echo %mydate% %mytime%>>%filename%
- echo.This program [ %%~nxF ] Was last modifide [ !diff! ] days ago.>>%filename%
- )
- echo.
- Echo Press any key to return to LOG....
- PAUSE>nul
- GOTO log
- :edit
- cls
- title Opening %logname%%ext% in text editor %title%
- call :c 0a " Opening "
- call :c 0c "%logname%%ext%"
- call :c 0f " in "
- call :c 0d "%editor%." /n
- ping -n 5 127.0.0.1 >nul
- echo.
- start %editor% %filename%
- ping -n 3 127.0.0.1 >nul
- cls
- goto log
- :c
- setlocal enableDelayedExpansion
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :colorPrint Color Str [/n]
- setlocal
- set "s=%~2"
- call :colorPrintVar %1 s %3
- exit /b
- :colorPrintVar Color StrVar [/n]
- if not defined DEL call :initColorPrint
- setlocal enableDelayedExpansion
- pushd .
- ':
- cd \
- set "s=!%~2!"
- :: The single blank line within the following IN() clause is critical - DO NOT REMOVE
- for %%n in (^"^
- ^") do (
- set "s=!s:\=%%~n\%%~n!"
- set "s=!s:/=%%~n/%%~n!"
- set "s=!s::=%%~n:%%~n!"
- )
- for /f delims^=^ eol^= %%s in ("!s!") do (
- if "!" equ "" setlocal disableDelayedExpansion
- if %%s==\ (
- findstr /a:%~1 "." "\'" nul
- <nul set /p "=%DEL%%DEL%%DEL%"
- ) else if %%s==/ (
- findstr /a:%~1 "." "/.\'" nul
- <nul set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%"
- ) else (
- >colorPrint.txt (echo %%s\..\')
- findstr /a:%~1 /f:colorPrint.txt "."
- <nul set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%"
- )
- )
- if /i "%~3"=="/n" echo(
- popd
- exit /b
- :initColorPrint
- for /f %%A in ('"prompt $H&for %%B in (1) do rem"') do set "DEL=%%A %%A"
- <nul >"%temp%\'" set /p "=."
- subst ': "%temp%" >nul
- exit /b
- :cleanupColorPrint
- 2>nul del "%temp%\'"
- 2>nul del "%temp%\."
- 2>nul del "%temp%\colorPrint.txt"
- >nul subst ': /d
- :exit
- cls
- exit /b
- ::0 = Black 8 = Gray
- ::1 = Blue 9 = Light Blue
- ::2 = Green A = Light Green
- ::3 = Aqua B = Light Aqua
- ::4 = Red C = Light Red
- ::5 = Purple D = Light Purple
- ::6 = Yellow E = Light Yellow
- ::7 = White F = Bright White
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement