Advertisement
kiriko

CMD Notes Logging System

Mar 16th, 2024
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 19.55 KB | Software | 0 0
  1. @echo off
  2. doskey /listsize=0
  3. color A
  4. REM -- Prepare the Command Processor
  5. SETLOCAL ENABLEEXTENSIONS
  6. SETLOCAL ENABLEDELAYEDEXPANSION
  7. REM -- Version History --DOS Batch - File Examples http://www.dostips.com/DtCodeBatchFiles.php
  8. ::: -- Version History
  9. ::: XX.XXX YYYYMMDD Author Description
  10. 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.
  11. 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.
  12. 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.
  13. 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.
  14. ::: !! For a new version entry, copy the last entry down and modify Date, Author and Description
  15. For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%a/%%b/%%c)
  16. For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a:%%b)
  17. ::echo %mydate% %mytime%
  18.  
  19.     set v_day=
  20.     set v_month=
  21.     set v_year=
  22.  
  23.     SETLOCAL ENABLEEXTENSIONS
  24.     if "%date%A" LSS "A" (set toks=1-3) else (set toks=2-4)
  25. ::DEBUG echo toks=%toks%
  26.       for /f "tokens=2-4 delims=(-)" %%a in ('echo:^|date') do (
  27. ::DEBUG echo first token=%%a
  28.         if "%%a" GEQ "A" (
  29.           for /f "tokens=%toks% delims=.-/ " %%i in ('date/t') do (
  30.             set '%%a'=%%i
  31.             set '%%b'=%%j
  32.             set 'yy'=%%k
  33.           )
  34.         )
  35.       )
  36.       if %'yy'% LSS 100 set 'yy'=20%'yy'%
  37.       set Today=%'yy'%-%'mm'%-%'dd'%
  38.  
  39.     ENDLOCAL & SET v_year=%'yy'%& SET v_month=%'mm'%& SET v_day=%'dd'%
  40.  
  41.     ::ECHO Today is Year: [%V_Year%] Month: [%V_Month%] Day: [%V_Day%]
  42.     set datestring=%V_Month%/%V_Day%/%V_Year%
  43.    ::echo %datestring%
  44.  
  45.     :EOF
  46.  
  47.    
  48.     SETLOCAL ENABLEEXTENSIONS
  49.     for /f "tokens=1-4 delims=:,.-/ " %%i in ('echo %time%') do (
  50.       set 'hh'=%%i
  51.       set 'mm'=%%j
  52.       set 'ss'=%%k
  53.       set 'ff'=%%l)
  54.     ENDLOCAL & SET v_Hour=%'hh'%& SET v_Minute=%'mm'%& SET v_Second=%'ss'%& SET v_Fraction=%'ff'%
  55.  
  56.     ::ECHO Now is Hour: [%V_Hour%] Minute: [%V_Minute%] Second: [%v_Second%] Fraction: [%v_Fraction%]
  57.     set timestring=%V_Hour%%V_Minute%%v_Second%.%v_Fraction%
  58.    ::echo %timestring%
  59.  
  60.     :EOF
  61.  
  62. cls
  63. ::: -- Set the window TITLE --
  64. SET "TITLE= %~nx0  Version %Version%"
  65. :create
  66.  
  67.                                         ::::::::::::::::::::::::::::::::::::::::::::::::
  68.                                         ::::::::::::: SETUP::SETUP::SETUP:::::::::::::::
  69.                                         ::::::::::::::start::start::start:::::::::::::::
  70.                                         ::::::::::::::::::::::::::::::::::::::::::::::::
  71.                                        
  72. REM this section sets the file destination, name, extension also the preferred text editor
  73. REM it is currently set to work and save directory as this bat file also the LOG file is invisible by default
  74.  
  75. REM Example directory( %SystemDrive%\Users\%USERNAME%\Desktop\ )
  76. set loc=%~dp0
  77. ::LOG File Extension
  78. set ext=.LOG
  79. ::LOG File Name
  80. set logname=mylogsystem
  81. REM set the preferred text editor
  82. set editor=notepad.exe
  83. REM this sets your user password on CMD (its case sensitive)
  84. set pass=PASSWORD
  85. REM this sets your user name on CMD (its case sensitive)
  86. set name=USERNAME
  87. :::::::::::::::::
  88. REM DO NOT EDIT
  89. set filename=%loc%%logname%%ext%
  90. REM this set the LOG file invisible by default.
  91.  
  92.                                         ::::::::::::::::::::::::::::::::::::::::::::::::
  93.                                         ::::::::::::: SETUP::SETUP::SETUP:::::::::::::::
  94.                                         :::::::::::::::END::::END::::END::::::::::::::::
  95.                                         ::::::::::::::::::::::::::::::::::::::::::::::::
  96.                                        
  97. Title Enter Your Name %Title%
  98. :name
  99. set ntries=4
  100. :1top
  101. cls
  102. echo.
  103. call :c 07 "Please enter username to proceed " /n
  104. echo       (do not use spaces)
  105. echo.
  106. set /a ntries=%ntries% -1
  107. if %ntries%==0 (
  108.  
  109. goto penalty
  110. )
  111. echo ------------------------------------
  112. call :c 04 "You have "
  113. call :c 0b "%ntries% "
  114. call :c 07 "attempts left." /n
  115. echo ------------------------------------
  116. echo.
  117. echo.
  118. doskey /listsize=0
  119. set /p "uname=                      User Name:"
  120. if %uname%==%name% (
  121. cls
  122. ping localhost -n 3 >nul
  123. cls
  124. doskey /listsize=0
  125. goto psw
  126. ) else (
  127. doskey /listsize=0
  128. goto 1top
  129. )
  130.  
  131.  
  132. :afk
  133. Title Away from Screen %Title%
  134. set atries=4
  135. :2top
  136. cls
  137. echo.
  138. call :c 07 "Enter Password to Proceed " /n
  139. echo.
  140. set /a atries=%atries% -1
  141. if %atries%==0 (
  142. goto penalty
  143. )
  144. echo ------------------------------------
  145. call :c 04 "You have "
  146. call :c 0b "%atries% "
  147. call :c 07 "attempts left." /n
  148. echo ------------------------------------
  149. echo.
  150. echo.
  151. set /p "password=                      User Password:"
  152. if %password%==%pass% (
  153. cls
  154. ping localhost -n 3 >nul
  155. cls
  156. doskey /listsize=0
  157. goto find
  158. ) else (
  159. doskey /listsize=0
  160. goto 2top
  161. )
  162.  
  163.  
  164.  
  165. REM you most set the password befor hand
  166. :psw
  167. :: By http://www.instructables.com/member/Necrohero/
  168.  
  169. Title Enter Your Password
  170. set ptries=4
  171. :top
  172. cls
  173. echo.
  174. call :c 07 "Please enter Password" /n
  175. echo.
  176. set /a ptries=%ptries% -1
  177. if %ptries%==0 (
  178. goto penalty
  179. )
  180. echo ------------------------------------
  181. call :c 0b " %name%, " 
  182. call :c 04 "You have "
  183. call :c 0b "%ptries% "
  184. call :c 07 "attempts left." /n
  185. echo ------------------------------------
  186. echo.
  187. echo.
  188. doskey /listsize=0
  189. set /p "password=                      User Password:"
  190. if %password%==%pass% (
  191. cls
  192. echo ###########
  193. call :c 07 " CONNECTED! " /n
  194. echo ###########
  195. echo.
  196. call :c 0b "Welcome, "
  197. call :c 09 "%name%"
  198. call :c 07 "@"
  199. call :c 0d "%ComputerName% " /n
  200. echo.
  201. echo.
  202. ping localhost -n 3 >nul
  203. cls
  204. doskey /listsize=0
  205. goto find
  206. ) else (
  207. doskey /listsize=0
  208. goto top
  209. )
  210.  
  211. :penalty
  212. Title Invalid Username or password!
  213. color c
  214. 
  215. cls
  216. ping localhost -n 2 >nul
  217. 
  218. cls
  219. ping localhost -n 2 >nul
  220. 
  221. cls
  222. ping localhost -n 2 >nul
  223. 
  224. cls
  225. ping localhost -n 2 >nul
  226. 
  227. cls
  228. ping localhost -n 2 >nul
  229. cls
  230. setlocal EnableDelayedExpansion
  231. set message=Ah Ah Ah, You Didn't Say The Magic Word...
  232. set messageLength=44
  233.  
  234. for /L %%J in (1,1,%messageLength%) do (
  235.     echo !message:~0,%%J!
  236.     ping localhost -n 1 >nul
  237.     cls
  238. )
  239. ping localhost -n 2 >nul
  240. cls
  241. echo ------------------------------------
  242. call :c 0f " Please Try Agian " /n
  243. echo ------------------------------------
  244. pause > nul
  245. goto exit
  246.  
  247. :find
  248. cls
  249. title Checking for %logname%%ext%
  250. echo.
  251. echo ------------------------------------
  252. call :c 0b " %name%, " 
  253. call :c 0d "Checking if "
  254. call :c 0c "%logname%%ext% "
  255. call :c 0d "file exist." /n
  256. echo ------------------------------------
  257. ping localhost -n 3 >nul
  258. echo.
  259. if exist %filename% (
  260.    
  261.     goto confirm
  262. ) else (
  263. echo ------------------------------------
  264. call :c 07 " File"
  265. call :c 0c " %logname%%ext% "
  266. call :c 04 "doesn't exist" /n
  267. echo ------------------------------------
  268. echo.
  269. call :c 0e "Press any key to start a new LOG " /n
  270. echo.
  271. pause >nul 
  272.     goto EULA
  273. )
  274.  
  275. :confirm
  276. title Loading...
  277. cls
  278. attrib "%filename%" +s +h
  279. echo.
  280. rem You can set the number of ()'s as whatever you
  281. rem want but remember: in your "loading box" you
  282. rem need 2 spaces for every () because "()" takes up
  283. rem 2 spaces. The above box has 40 spaces, so
  284. rem twenty repeats, adding 1 () every repeat.
  285. rem https://www.instructables.com/Loading-effect-in-batch/#step1
  286. set load=
  287. set/a loadnum=0
  288. :Loading
  289. set load=%load%/
  290. cls
  291. echo.
  292. echo                      %name%, Loading file %logname%%ext%
  293. echo.
  294. echo.           ========================================
  295. echo.           %load%
  296. echo.           ========================================
  297. echo                                              Please Wait...
  298. echo.
  299. ping localhost -n 1>nul
  300. set/a loadnum=%loadnum% +1
  301. if %loadnum%==40 goto Done
  302.  
  303. goto Loading
  304.  
  305. :Done
  306. cls
  307. echo.
  308. echo.
  309. echo            -------------------------------------------------
  310. echo                                   Done
  311. echo            -------------------------------------------------
  312. echo.
  313. echo                           #
  314. echo                         #
  315. echo                 #     #            Loading Successfully
  316. echo                  #  #
  317. echo                   #
  318. echo.
  319. echo.
  320. echo             -------------------------------------------------
  321. ping -n 5 127.0.0.1 >nul
  322. echo.>>%filename%
  323. echo %mydate% %mytime%>>%filename%
  324. echo %name% Has logged in.>>%filename%
  325. echo.>>%filename%
  326. goto start
  327.  
  328. :name2
  329. Title Change User Name %Title%
  330. cls
  331. echo.
  332. call :c 09 "%name%, "
  333. call :c 07 "Type your New Name "
  334. call :c 0d "(do not use spaces)" /n
  335. echo.
  336. echo.
  337. :sellect4
  338. echo.
  339. set /p C=%name%:
  340. SET name=%C%
  341. cls
  342. echo.
  343. echo.>>%filename%
  344. echo.
  345. call :c 09 "%name%, "
  346. call :c 07 "Type your old Name "
  347. call :c 0d "(do not use spaces) "
  348. call :c 07 "to indicate who you are going to be known as." /n
  349. echo.
  350. set /p old=Old Name:%old%
  351. echo.
  352. echo %mydate% %mytime%>>%filename%
  353. echo %old% logged out>>%filename%
  354. echo.>>%filename%
  355. echo %mydate% %mytime%>>%filename%
  356. echo New User %name% Logged in>>%filename%
  357. goto psw
  358.  
  359. :help
  360. cls
  361. Title Help
  362. echo.
  363. echo Here are other commands that can be used!
  364. echo.
  365. Echo Type any of these
  366. Echo [ /clear /nick /log /age /edit /about /afk /exit]
  367. Echo commands to make changes to your LOG.
  368. echo.
  369. Echo Use /clear  to delete LOG.
  370. echo.
  371. Echo Use /nick  to change your name.
  372. echo.
  373. Echo Use /age  to see if %~nx0 was tamperd with.
  374. Echo.
  375. Echo Use /edit  to open LOG fiel in text editor.
  376. Echo.
  377. echo Use /about for small intro
  378. echo.
  379. echo Use /afk you most re-enter your password.
  380. echo.
  381. echo Use /exit to quit program
  382. echo.
  383. Echo Press any key to return to LOG....
  384. pause >nul
  385. goto log
  386.  
  387. :about
  388. cls
  389. TITLE MyLog %title% %Version%
  390. echo.
  391. call :c 0a "   %TITLE%" /n
  392. call :c 0b "    Danny Muniz" /n
  393. call :c 0e "    dannym2785@gmail.com " /n
  394. call :c 0c "    (C) Copyright 2020 - %V_Year%" /n
  395. call :c 0e "    All rights reserved" /n
  396. ECHO.  
  397. echo.
  398. call :c 0e "   Description" /n
  399. call :c 0e "   -----------" /n
  400. echo.
  401. call :c 0b " %name%, "
  402. call :c 0e "( "
  403. call :c 02 "%~nx0"
  404. call :c 0e " ) "
  405. call :c 0f "My Personal Log File"
  406. call :c 0e " ( "
  407. call :c 0c "%ComputerName%"
  408. call :c 0e " )" /n
  409. ECHO.  
  410. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  411. ::                              Do Not deleted
  412. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  413. echo.
  414. call :c 0c "            License Agreement" /n
  415. call :c 0c "            ------------------" /n
  416. echo.
  417. ECHO            This software is distributed free of charge. It may be used as many times as  you^
  418.  like, for as long as you like, in a domestic or corporate environment. You may^
  419.  copy and distribute copies of this program provided that you keep all original^
  420.  documentation including this License Agreement with copyright notice and^
  421.  disclaimer of warranty intact. You may not charge money or fees for the software^
  422.  product to anyone.
  423. ECHO.  
  424. echo.
  425. call :c 0c "            Warranty" /n
  426. call :c 0c "            -----------" /n
  427. echo.
  428. ECHO            This program is provided "as is" without warranties of any kind, either^
  429.  expressed or implied, including, but not limited to, the implied warranties of^
  430.  merchantability and fitness for a particular purpose. The entire risk as to the^
  431. quality and performance of the program is with you. Should the program prove^
  432.  defective, you assume the cost of all necessary servicing, repair or correction.^
  433.  In no event will any copyright holder be liable to you for damages, including^
  434.  any general, special, incidental or consequential damages arising out of the use^
  435.  or inability to use the program (including but not limited to loss of data or^
  436.  data being rendered inaccurate or losses sustained by you or third parties or a^
  437.  failure of the program to operate with any other programs).
  438. echo.
  439. echo.
  440. echo.
  441. call :c 0f " Press Any Key To Return" /n
  442. pause >nul
  443. cls
  444. goto log
  445. :EULA
  446. cls
  447. echo.
  448. TITLE MyLog %title% %Version%
  449. echo.
  450. call :c 0a "   %TITLE%" /n
  451. call :c 0b "    Danny Muniz" /n
  452. call :c 0e "    dannym2785@gmail.com " /n
  453. call :c 0c "    (C) Copyright 2020 - %V_Year%" /n
  454. call :c 0e "    All rights reserved" /n
  455. ECHO.  
  456. echo.
  457. call :c 0e "   Description" /n
  458. call :c 0e "   -----------" /n
  459. echo.
  460. call :c 0b " %name%, "
  461. call :c 0e "( "
  462. call :c 02 "%~nx0"
  463. call :c 0e " ) "
  464. call :c 0f "My Personal Log File"
  465. call :c 0e " ( "
  466. call :c 0c "%ComputerName%"
  467. call :c 0e " )" /n
  468. ECHO.  
  469. ping -n 5 127.0.0.1 >nul
  470. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  471. ::                              Do Not deleted
  472. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  473. echo.
  474. call :c 0c "            License Agreement" /n
  475. call :c 0c "            ------------------" /n
  476. echo.
  477. ECHO            This software is distributed free of charge. It may be used as many times as  you^
  478.  like, for as long as you like, in a domestic or corporate environment. You may^
  479.  copy and distribute copies of this program provided that you keep all original^
  480.  documentation including this License Agreement with copyright notice and^
  481.  disclaimer of warranty intact. You may not charge money or fees for the software^
  482.  product to anyone.
  483. ECHO.  
  484. echo.
  485. call :c 0c "            Warranty" /n
  486. call :c 0c "            -----------" /n
  487. echo.
  488. ECHO            This program is provided "as is" without warranties of any kind, either^
  489.  expressed or implied, including, but not limited to, the implied warranties of^
  490.  merchantability and fitness for a particular purpose. The entire risk as to the^
  491. quality and performance of the program is with you. Should the program prove^
  492.  defective, you assume the cost of all necessary servicing, repair or correction.^
  493.  In no event will any copyright holder be liable to you for damages, including^
  494.  any general, special, incidental or consequential damages arising out of the use^
  495.  or inability to use the program (including but not limited to loss of data or^
  496.  data being rendered inaccurate or losses sustained by you or third parties or a^
  497.  failure of the program to operate with any other programs).
  498. echo.
  499. echo.
  500. call :c 0e "            Important NOTE: " /n
  501. call :c 0e "            ---------------" /n
  502. echo            Make sure to setup your password and username within this file.
  503. echo.
  504. echo.
  505. call :c 0a " [1]- Yes" /n
  506. call :c 0c " [2]- No" /n
  507. echo.
  508. doskey /listsize=0
  509. set /p C=Do you agree?:
  510. cls
  511. if "%C%"=="1" goto first
  512. if "%C%"=="2" goto exit
  513. cls
  514. goto EULA
  515.  
  516. :first
  517. cls
  518. echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::>>%filename%
  519. echo %title% %filename% >>%filename%
  520. echo created by (%Name%@%ComputerName%) %mytime% %mydate%>>%filename%
  521. echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::>>%filename%
  522. cls
  523. goto find
  524. ::::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  525. :start
  526.  
  527. :log
  528. cls
  529. For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%a/%%b/%%c)
  530. For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a:%%b)
  531. Title %title%
  532. type %filename%
  533. echo.
  534. ECHO.
  535. echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  536. :: This tells how big is the LOG file.  thanks to DosTips.com
  537. for %%A in (%filename%) do ECHO ::: Log File Size [ %logname%%ext% ] is [ %%~zA ] Bytes
  538. echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  539. call :c 0e " :::    Enter Your Memo Text    "
  540. call :c 0A " :::"
  541. call :c 0d " For Help type /help" /n
  542. echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  543. echo.
  544. echo.
  545. doskey /listsize=0
  546. set /p C=%name%:
  547. echo.>>%filename%
  548. echo %mydate% %mytime%>>%filename%
  549. echo %name%: %C% >>%filename%
  550. echo.>>%filename%
  551. if "%C%"=="/clear" goto del
  552. if "%C%"=="/nick" goto name2
  553. if "%C%"=="/help" goto help
  554. if "%C%"=="/age" goto age
  555. if "%C%"=="/edit" goto edit
  556. if "%C%"=="/hide" goto secret
  557. if "%C%"=="/unhide" goto nosecret
  558. if "%C%"=="/about" goto about
  559. if "%C%"=="/afk" goto afk
  560. if "%C%"=="/exit" goto exit
  561. cls
  562. goto log
  563. :del
  564. cls
  565. Title Warning!! %Title%
  566. echo ##############
  567. Echo #-Warning!!!!! -#
  568. echo ##############
  569. echo.
  570. Echo You are about to Delete %filename%
  571. echo.
  572. echo A new %filename% file will be automaticly created.
  573. echo.
  574. echo [1]-Yes
  575. echo [2]-No
  576.  
  577. :sellect6
  578. set /p C=Sellection:
  579. doskey /listsize=0
  580. if "%C%"=="1" goto del2
  581. if "%C%"=="2" goto log
  582.  
  583. :: this will the delete the log on command
  584. :del2
  585. attrib "%filename%" -s -h
  586. del %filename%
  587. :: this tells who deleted the log
  588. :chat4
  589. For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%a/%%b/%%c)
  590. For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a:%%b)
  591. echo.>>%filename%
  592. echo [%mydate% %mytime%] %name% has deleted the LOG file [ %filename% ] >>%filename%
  593. echo.>>%filename%
  594. attrib "%filename%" +s +h
  595. cls
  596. goto EULA
  597.  
  598. :nosecret
  599. echo %mydate% %mytime%>>%filename%
  600. echo %name% has unhidden the LOG file [ %filename% ]>>%filename%
  601. attrib "%filename%" -s -h
  602. ping -n 2 127.0.0.1 >nul
  603. cls
  604. goto log
  605.  
  606. :secret
  607. echo %mydate% %mytime%>>%filename%
  608. echo %name% has hidden the LOG file [ %filename% ]>>%filename%
  609. attrib "%filename%" +s +h
  610. ping -n 2 127.0.0.1 >nul
  611. cls
  612. goto log
  613.  
  614. :: this section tells you how long ago the batch fiel was modifide.  thanks to DosTips.com
  615. :age
  616. cls
  617.  
  618. echo.
  619. echo This is just a way to seen if %~nx0 was tamperd with.
  620. echo.
  621. echo.
  622. cd /d "%loc%"
  623.  
  624. call:jdate tnow "%date%"
  625. for %%F in (%~nx0) do (
  626.     call:ftime tfile "%%F"
  627.     set /a diff=tnow-tfile
  628.     cls
  629.     echo.This program [ %%~nxF ] Was last modifide [ !diff! ] days ago.
  630.     echo.>>%filename%
  631.     echo %mydate% %mytime%>>%filename%
  632.     echo.This program [ %%~nxF ] Was last modifide [ !diff! ] days ago.>>%filename%
  633. )
  634. echo.
  635. Echo Press any key to return to LOG....
  636. PAUSE>nul
  637. GOTO log
  638.  
  639.  
  640. :edit
  641. cls
  642. title Opening %logname%%ext% in text editor %title%
  643. call :c 0a " Opening "
  644. call :c 0c "%logname%%ext%"
  645. call :c 0f " in "
  646. call :c 0d "%editor%." /n
  647. ping -n 5 127.0.0.1 >nul
  648. echo.
  649. start %editor% %filename%
  650. ping -n 3 127.0.0.1 >nul
  651. cls
  652. goto log
  653.  
  654. :c
  655. setlocal enableDelayedExpansion
  656. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  657.  
  658. :colorPrint Color  Str  [/n]
  659. setlocal
  660. set "s=%~2"
  661. call :colorPrintVar %1 s %3
  662. exit /b
  663.  
  664. :colorPrintVar  Color  StrVar  [/n]
  665. if not defined DEL call :initColorPrint
  666. setlocal enableDelayedExpansion
  667. pushd .
  668. ':
  669. cd \
  670. set "s=!%~2!"
  671. :: The single blank line within the following IN() clause is critical - DO NOT REMOVE
  672. for %%n in (^"^
  673.  
  674. ^") do (
  675.   set "s=!s:\=%%~n\%%~n!"
  676.   set "s=!s:/=%%~n/%%~n!"
  677.   set "s=!s::=%%~n:%%~n!"
  678. )
  679. for /f delims^=^ eol^= %%s in ("!s!") do (
  680.   if "!" equ "" setlocal disableDelayedExpansion
  681.   if %%s==\ (
  682.     findstr /a:%~1 "." "\'" nul
  683.     <nul set /p "=%DEL%%DEL%%DEL%"
  684.   ) else if %%s==/ (
  685.     findstr /a:%~1 "." "/.\'" nul
  686.     <nul set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%"
  687.   ) else (
  688.     >colorPrint.txt (echo %%s\..\')
  689.     findstr /a:%~1 /f:colorPrint.txt "."
  690.     <nul set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%"
  691.   )
  692. )
  693. if /i "%~3"=="/n" echo(
  694. popd
  695. exit /b
  696.  
  697.  
  698. :initColorPrint
  699. for /f %%A in ('"prompt $H&for %%B in (1) do rem"') do set "DEL=%%A %%A"
  700. <nul >"%temp%\'" set /p "=."
  701. subst ': "%temp%" >nul
  702. exit /b
  703.  
  704.  
  705. :cleanupColorPrint
  706. 2>nul del "%temp%\'"
  707. 2>nul del "%temp%\."
  708. 2>nul del "%temp%\colorPrint.txt"
  709. >nul subst ': /d
  710. :exit
  711. cls
  712. exit /b
  713.  
  714. ::0 = Black       8 = Gray
  715. ::1 = Blue        9 = Light Blue
  716. ::2 = Green       A = Light Green
  717. ::3 = Aqua        B = Light Aqua
  718. ::4 = Red         C = Light Red
  719. ::5 = Purple      D = Light Purple
  720. ::6 = Yellow      E = Light Yellow
  721. ::7 = White       F = Bright White
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement