T3RRYT3RR0R

Batch Custom Prompt Macro

Feb 16th, 2020
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.20 KB | None | 0 0
  1. @ECHO OFF & Setlocal EnableDelayedExpansion & TITLE %~n0
  2. cls & MODE 1000 & CD %userprofile%\desktop
  3.  
  4. Setlocal DisableDelayedExpansion
  5. set LF=^
  6.  
  7.  
  8. ::Above 2 blank lines are required - do not remove
  9. set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
  10.  
  11. Set @Macro.Prompt=For /L %%n in (1 1 2) do if %%n==2 (%\n%
  12.     For /F "tokens=1 delims=," %%G in ("!argv!") do (%\n%
  13.     For /F "tokens=* Delims=\" %%A In ("!USERPROFILE!") Do (Set C_Prompt=%%A)%\n%
  14.     Set C_Prompt=!C_Prompt:\=!%\n%
  15.     Set C_Prompt=!C_Prompt:Users=!%\n%
  16.     Set C_Prompt=!C_Prompt:Desktop=!%\n%
  17.     For %%A in (a,b,c,d,e,f,g,h,i) Do (Set C_Prompt=!C_Prompt:%%A:=!)%\n%
  18.     Set DirPath=%%G%\n%
  19.     Set DirPath=!DirPath:\=/!%\n%
  20.     Set DirPath=!DirPath: =!%\n%
  21.     Set C_Prompt=!C_Prompt! @ !computername! In: !DirPath! $$  %\n%
  22.     Prompt !C_Prompt! %\n%
  23.     ) %\n%
  24. ) ELSE setlocal enableDelayedExpansion ^& set argv=,
  25.  
  26. :loop
  27. %@Macro.Prompt% %CD%
  28. Set /P command=%C_Prompt%
  29. Call :WhatIf command
  30. %command% 2>nul
  31. Goto :Loop
  32.  
  33. :WhatIf
  34.     Set "tmp=!%~1!"
  35.     If /I "!tmp:~0,3!"=="For" (Exit /B)
  36.     If /I "!tmp:~0,2!"=="If" (Exit /B)
  37.     For /F "tokens=*" %%A in ("!%1!") Do (
  38.         %%A >nul 1>nul 2>nul || ECHO( "%%A" Not succesful && Goto :Loop
  39.     )
  40.     Exit /B
Advertisement
Add Comment
Please, Sign In to add comment