Test Foro de elhacker.net SMF 2.1

Programación => Scripting => Mensaje iniciado por: ne0x en 27 Abril 2007, 14:19 PM

Título: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: ne0x en 27 Abril 2007, 14:19 PM
Bien siempre tuve esta idea de ir recompilando algunos scripts buenos que veia, no solo mios.

La mayoria o son funciones o pueden adaptarse para ello.

Esta lista se ira actualizando poco a poco...


Renombrar un archivo a su fecha de creación:



: Sintaxis
: nombrebat archivo_a_renombrar
: Autor ne0x

@echo off
if not exist %1 echo Error ! & goto :EOF
set fechaYhora=%~t1
set fecha=%fechaYhora:~0,10%
set fecha=%fecha:/=-%
ren %1 %fecha%%~x1



Scripts NetBIOS


Primero hace ping's y despues checa NetBIOS:


    @echo off
:: Script de scanner NetBIOS por ne0x
set /p ip=3 primeros grupos Ip :
if .%ip%==. echo Error&goto END

FOR /L %%a IN (1,1,225) DO (
   ping -n 1 %ip%.%%a | find "Respuesta desde" && echo %ip%.%%a >> tmp.tmp
)
  FOR /F %%a IN (tmp.tmp) DO (
     nbtstat -a %%a | find "<20>"
     )
del tmp.tmp

:END
echo Pulse una tecla para salir
pause>nul
exit 0




Intenta iniciar sesion nula y si lo consigue lo muestra



    @echo off
:: Script de scanner NetBIOS por ne0x
set /p ip=3 primeros grupos de la ip :
if .%ip%==%ip% exit 1
FOR /L %%i IN (1,1,255) DO net use \\%ip%.%%i\ipc$ "" /u:"" 2>> nul && echo Sesion nula en : %ip%.%%i





Usa una lista de users y pass para conseguir accesos


    @echo off
:: Script de scanner NetBIOS por ne0x
set /p ip=Escribe la ip
if .%ip%==. exit 1
for /f %%a IN (ruta_logins) DO (
  FOR /F %%i IN (ruta_pass) DO net use \\%ip%\ipc$ %%i /u:%%a >nul &&
echo IP: %ip% login: %%a pass: %%i
)



Basados en un antiguo texto del foro de HxC


Algoritmos de búsquedas


Buscar comandos en todos los archivos por lotes, FOR:


:: Autor ne0x
echo. > %TMP%\lista.tmp
for %%A IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO (
   if exist %%A:\ (
      cd /D %%A:\
      for /R %%E IN (*.cmd) DO echo %%E >> %TMP%\lista.tmp
      for /R %%E IN (*.bat) DO echo %%E >> %TMP%\lista.tmp
      )
      )
for /F %%I IN (lista de comandos) DO (
    for /F %%J IN (%TMP%\lista.tmp) DO (
      find "%%I" "%%J" > nul
      if %errorlevel%==0 echo Comando %%I encontrado en %%J
     )
     )




Función Sleep



:: Autor ne0x
:: Declaración de la función

:sleep
:: Sintaxis:
:: call:sleep [-s/-m] [x]

:: -s Indicamos los segundos a esperar
:: -m Indicamos los milisegundos a esperar
:: x Cantidad de segundos/milisegundos a esperar

if %1==-s (set /a tiempo=1+%2 && ping -n %tiempo% 127.0.0.1 > nul )
if %1==-m (ping -n 1 127.0.0.1 -w %2 > nul)
goto:EOF



Calcular raices



:: Autor Sdc
@echo off
if NOT "%~1"=="vv" (cmd /v /c %~nx0 vv^&exit&goto:EOF)
set /P x=Valor:
FOR /L %%i IN (%x%,-2,1) DO (
set /A y=%x%/%%i
IF /I !y! EQU %%i (
echo %%i
goto:EOF
)
)



:: Autor ne0x
@echo off
set /P x=Valor :
:BUCLE
set /a cont=cont+1
set /a multi=cont*cont
if %multi%==%x% echo Raiz: %cont%&pause&goto:EOF
if %multi% GTR %x% echo El valor no tiene raiz entera&pause&goto:EOF
goto BUCLE


Calcular potencias


:: Autor ne0x
@echo off
set /P BASE=Base :
set /P EXPONENTE=Exponente :
if %BASE%.==. exit 1
if %EXPONENTE%.==. exit 1
set resultado=1
FOR /L %%A IN (1,1,%EXPONENTE%) DO set /A resultado=resultado*BASE
echo Resultado : %resultado%
goto:EOF




Función, saber las lineas de un archivo




:: Autor ne0x
:: Sintaxis

:: call:lineas [ruta] [variable]
:: ruta Ruta del archivo
:: variable Nombre de la variable en la que se almacenara el resultado

:lineas
set cont=0
if not exist %1 goto:EOF
for /F %%A IN (%1) DO call:texto
set %2=%cont%
goto:EOF

:texto
set /a cont=1+cont
goto:EOF


Funcion GetOS:


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:GetOS os
::
:: By:   Ritchie Lawrence, 2003-09-18. Version 1.0
::
:: Func: Returns the O/S version; NT40, 2000, 2002 or 2003.
::       For NT4/2000/XP/2003.
::
:: Args: %1 var to receive O/S version (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS & set "cmd=net config work^|findstr/b /c:"Soft""
for /f "tokens=1-2 delims=." %%a in ('%cmd%') do (
  for %%z in (%%a%%b) do set o=%%z)
endlocal & set "%1=%o:40=NT40%" & (goto :EOF)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Funciones de comprobaciones

Funcion, averiguar si un servicio esta corriendo:


:: Autor ne0x
:: Sintaxis:

:: call:svc nombre variable
:: nombre Nombre del servicio a chequear
:: variable Nombre de la variable en la que se pondra la respuesta en dato boleano

:svc
net start | find "%~1" > nul
if %errorlevel%==0 (
set %2=0
  ) ELSE (
set %2=1
)
goto:EOF


Funcion, averiguar si se ha iniciado un proceso:


:: Autor ne0x
:: Sintaxis

:: call:pr nombre variable
:: nombre Nombre del proceso a chequear
:: variable Nombre de la variable en la que se guardara la respuesta en tipo boleano.

:pr
taskklist | find "%~1"
if %errorlevel%==0 (
set %2=0
  ) ELSE (
set %2=1
)
goto:EOF



Funcion TIMER



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:Timer ID
::
:: By:   Ritchie Lawrence, 2002-10-10. Version 1.0
::
:: Func: Returns number of seconds elapsed since the function was last
::       called and first called. For NT4/2000/XP/2003.
::
:: Args: %1 (by ref) The first time this function is called, this variable
::       is initialised to '<last> <first> <init>' where <last> and <first>
::       are zero and <init> is the number of elapsed seconds since
::       1970-01-01 00:00:00. This value is used by subsequent calls to
::       determine the elapsed number of seconds since the last call
::       (<last>) and the first call (<first>).
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS&call set ID=%%%1%%
set t=2&if "%date%z" LSS "A" set t=1
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo/^|date') do (
  for /f "tokens=%t%-4 delims=.-/ " %%d in ('date/t') do (
    set %%a=%%d&set %%b=%%e&set %%c=%%f))
for /f "tokens=5-7 delims=:. " %%a in ('echo/^|time') do (
  set hh=%%a&set nn=%%b&set ss=%%c)
set /a dd=100%dd%%%100,mm=100%mm%%%100
set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2
set /a j=j/5+dd+y*365+y/4-y/100+y/400-2472633
set /a hh=100%hh%%%100,nn=100%nn%%%100,ss=100%ss%%%100
set /a j=j*86400+hh*3600+nn*60+ss
for /f "tokens=1-3 delims= " %%a in ('echo/%ID%') do (
  set l=%%a&set f=%%b&set c=%%c)
if {%c%}=={} endlocal&set %1=0 0 %j%&goto :EOF
set /a l=j-c-l,f+=l
endlocal&set %1=%l% %f% %c%&goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Funcion, obtener Puerta de enlace:


:: Autor ne0x
:: Sintaxis

:: call:dg  variable
:: variable Nombre de la variable en la que se almacenara la IP de la puerta de enlace

:dg
ipconfig | find "Puerta de enlace . . . . . 1" > %TMP%\rd.tmp
for /F %%A "tokens=11" IN (%TMP%\rd.tmp) DO set %2=%%A
goto:EOF



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:GetDG dg
::
:: By:   Ritchie Lawrence, 2003-09-22. Version 1.0
::
:: Func: Obtains the default gateway. For NT4/2000/XP/2003.
::       If functions fails, 0.0.0.0 is returned.
::
:: Args: %1 var to receive default gateway (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS & set "g=0.0.0.0" & set "j="
for /f "tokens=3" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (
  if not defined j for %%b in (%%a) do set "g=%%b" & set "j=1")
endlocal & set "%1=%g%" & goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Funcion GetIP


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:GetIP ip
::
:: By:   Ritchie Lawrence, 2003-09-22. Version 1.0
::
:: Func: Obtains the IP address of primary adapter. For NT4/2000/XP/2003.
::       If functions fails, 0.0.0.0 is returned.
::
:: Args: %1 var to receive IP address (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS & set "i=0.0.0.0" & set "j="
for /f "tokens=4" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (
  if not defined j for %%b in (%%a) do set "i=%%b" & set "j=1")
endlocal & set "%1=%i%" & goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Funcion GetMAC


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:GetMAC mac
::
:: By:   Ritchie Lawrence, 2003-09-24. Version 1.0
::
:: Func: Obtains the MAC address of the primary adapter in the format of
::       XX-XX-XX-XX-XX-XX. If the function fails 00-00-00-00-00-00 is
::       returned. For NT4/2000/XP/2003.
::
:: Args: %1 var to receive MAC address (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS & set "m=00-00-00-00-00-00" & set "i=" & set "j="
set "n=0" & set "c=ipconfig/all" & set "f=findstr"
for /f "tokens=4" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (
  if not defined j for %%b in (%%a) do set "i=%%b" & set "j=1") & set "j="
if not defined i endlocal & set "%1=%m%" & goto :EOF
for /f "delims=:" %%a in ('%c%^|%f%/n IP.Address.*%i%') do set /a n=%%a-6
for /f "delims=" %%a in ('%c%^|more/e +%n%^|%f% Physical.Address') do (
  if not defined j for %%b in (%%a) do set "m=%%b" & set "j=1")
endlocal & set "%1=%m%" & goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



Funcion GetNA

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:GetNA na
::
:: By:   Ritchie Lawrence, 2003-09-22. Version 1.0
::
:: Func: Obtains network address of primary adapter. For NT4/2000/XP/2003.
::       If functions fails, 0.0.0.0 is returned.
::
:: Args: %1 var to receive network address (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS & set "i=0.0.0.0" & set "n=0.0.0.0" & set "j="
for /f "tokens=4" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (
if not defined j (for %%b in (%%a) do set "i=%%b" & set j=1)) & set "k="
for /f "skip=1 tokens=1,3-4" %%a in ('route print^|findstr/b /c:" "') do (
  for %%e in (%%a) do set "x=%%e" & for %%f in (%%b) do set "y=%%f"
  for %%g in (%%c) do set "z=%%g"
  for /f "tokens=1-3" %%a in ('echo/%%x%% %%y%% %%z%%') do (
    if not defined k if "%%c"=="%i%" if "%%b"=="%i%" set k=1 & set n=%%a))
endlocal & set "%1=%n%" & goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Funcion GetSM


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:GetSM sm
::
:: By:   Ritchie Lawrence, 2003-09-22. Version 1.0
::
:: Func: Obtains the subnet mask of primary adapter. For NT4/2000/XP/2003.
::       If functions fails, 0.0.0.0 is returned.
::
:: Args: %1 var to receive subnet mask (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS & set "i=0.0.0.0" & set "m=0.0.0.0" & set "j="
for /f "tokens=4" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (
  if not defined j (for %%b in (%%a) do set "i=%%b" & set j=1)) & set "k="
for /f "skip=1 tokens=2-4" %%a in ('route print^|findstr/b /c:" "') do (
  for %%e in (%%a) do set "x=%%e" & for %%f in (%%b) do set "y=%%f"
  for %%g in (%%c) do set "z=%%g"
  for /f "tokens=1-3" %%a in ('echo/%%x%% %%y%% %%z%%') do (
    if not defined k if "%%c"=="%i%" if "%%b"=="%i%" set k=1 & set m=%%a))
endlocal & set "%1=%m%" & goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   

Script para extraer el PID de un proceso



@echo off
:: Script para extraer el PID de un proceso
:: By Sdc
FOR /F "tokens=1,2" %%i IN ('tasklist') DO (
IF "%%i"=="PROCESO1.exe" (
SET pid1=%%j
)
IF "%%i"=="PROCESO2.EXE" (
SET pid2=%%j
)
)




Script para extraer el valor de una clave del registro


@echo off
:: Script para extraer el valor de una clave del registro
:: By nhaalclkiemr
:: Special thanks to Sdc
reg export "RUTA_CLAVE" "temp.tmp"
if not %errorlevel%==0 goto error
type temp.tmp | find "NOMBRE_CLAVE" > cadena_encontrada.tmp
del /S /F /Q /A:- temp.tmp
FOR /F "tokens=2* delims==" %%I IN (cadena_encontrada.tmp) DO set var="%%I"
if "%var%"=="" goto error
FOR /F "tokens=2* delims==" %%I IN (cadena_encontrada.tmp) DO (
call:PARSEA %%I
)
goto :EOF
:PARSEA
del /S /F /Q /A:- cadena_encontrada.tmp
SET PP="%~1"
SET PP=%PP:\\=\%
SET PP=%PP:"=%
:: Aqui va el bat, el valor de la clave queda guardado en la variable PP
exit
:error
:: Aqui va el bat de error en caso de que la RUTA_CLAVE o NOMBRE_CLAVE no exista
exit




Script para ejecutar un archivo BAT con salida nula


@echo off
:: Script para ejecutar un archivo BAT con salida nula
:: By nhaalclkiemr
if exist temp.bat goto mibat
copy /Y %0 temp.bat>>NUL
call temp.bat>>NUL
exit
:mibat
:: Aqui va el bat
del /S /F /Q /A:- temp.bat
exit



Conocer si el valor de una variable es un numero o otro caracter


:: Conocer si el valor de una variable es un numero o otro caracter
:: By Sdc
:: Aqui partimos de que tenemos una variable r
set /a x=%r%*1
if "%x%"=="%r%" (REM Es un numero) else (REM No es un numero)




Ejecutar una aplicación como SYSTEM



@echo off
:: Ejecutar una aplicación como SYSTEM
:: Puedes ejecutarla inmediatamente o programarla para cuando quieras
:: Tal como está el codigo está programado para ejecutar al intantante la aplicación
:: Borra los comentarios REM para ahorrar codigo y fijate en lo que pone
:: By nhaalclkiemr
set a=0
set z=%TIME:~0,2%
if "%TIME:~0,1%"==" " set z=0%TIME:~1,1%
if "%TIME:~8,1%"=="," goto normal
if "%TIME:~10,1%"=="," goto 2caso
if "%TIME:~12,1%"=="," goto 3caso
:normal
set x=%TIME:~3,2%
goto a
:2caso
set x=%TIME:~4,2%
goto a
:3caso
set x=%TIME:~5,2%
:a
set /A a=%a%+1
if "%x%"=="08" set x=8
if "%x%"=="09" set x=9
if "%a%"=="1" set /A x=%x%+1
REM El segundo 1 especifica el tiempo en minutos que tardará en ejecutarse la aplicación, es modificable
REM Solo se puede sumar como máximo 86400 minutos, de lo contrario pueden producirse errores
:e
if %x% GTR 59 set /A z=%z%+1
if %z% GTR 23 set /A z=%z%-24
for /L %%A in (0,1,9) do if "%z%"=="%%A" set z=0%z%
if %x% GTR 59 set /A x=%x%-60
if %x% GTR 59 goto e
at.exe %z%:%x% AQUITUPROGRAMA.EXE
REM En lugar de lo anterior puedes poner lo siguiente si quieres que la aplicacion sea visible:
REM at.exe %z%:%x% /interactive AQUITUPROGRAMA.EXE
REM %z% y %x% son la hora y los minutos a los que se ejecutará la aplicación, puedes poner otra cosa si quieres
if %a%==11 goto b
if not %errorlevel%==0 goto a
schtasks /run /tn at1
REM Esta ultima linea ejecuta inmediatamente la aplicación, si la estás programando para una hora determinada borra esta linea
exit
:b
set a=0
if %x% LEQ 9 set x=0%x%
:c
set /A a=%a%+1
schtasks /create /tn temp /tr AQUITUPROGRAMA.EXE /sc once /st %z%:%x%:00 /ru System
REM Esto se ejecutará en caso de que el comando AT falle, es un intento alternativo, de esta manera no se puede hacer visible
if %a%==11 goto error
if not %errorlevel%==0 goto c
schtasks /run /tn temp
REM Esta ultima linea ejecuta inmediatamente la aplicación, si la estás programando para una hora determinada borra esta linea
exit
:error
:: Aqui va el BAT que se ejecuta en caso de que se produzca un error



Configuracion IP


:: Autor: pantocrator
:: MAs información: http://pantocrator-blog.blogspot.com/

@Echo OFF
echo [requerido] Primer parametro %1 es para ip estatica.
echo [requerido] Segundo parametro %2 es la mascara de red.
echo [requerido] Tercer parametro %3 es la puerta de enlace.
echo [opcional] Cuarto parametro %4 es el servidor dns primario
If [%1] == [] GOTO QUIT
If [%2] == [] GOTO QUIT
If [%3] == [] GOTO QUIT
echo Starting %0
Echo ....................Configurando IP address en Conexi¢n de rea local a %1 con NetMask %2
netsh interface ip set address name="Conexi¢n de rea local" source=static addr=%1 mask=%2
Echo ....................Configurando Gateway en Conexi¢n de rea local a %3
netsh interface ip set address name="Conexi¢n de rea local" gateway=%3 gwmetric=1
If [%4] == [] GOTO QUIT
Echo ....................Configurando DNS en Conexi¢n de rea local a %4
netsh interface ip set dns name="Conexi¢n de rea local" source=static addr=%4 register=primary
GOTO QUIT

:QUIT
ECHO ON
Título: Funcion de DEC2HEX en batch
Publicado por: sirdarckcat en 2 Octubre 2007, 07:53 AM
Lo hice para otro programa, pero les podría servir..
Código (bash) [Seleccionar]
:dec2hex
set hexstr=0123456789ABCDEF
set last=
set /A dec= %1
:loop2
set /A ths=%dec% %% 16
call:evals "%%hexstr:~%ths%,1%%"
if /I %dec% GEQ 16 (
set /A dec=%dec%/16
) else (
goto:EOF
)
goto:loop2
goto:EOF
:evals
set last=%~1%last%
goto:EOF

la funcion (call:dec2hex %numero%) recibe como unico argumento el numero en decimal, y regresara en %last% el numero en hexadecimal.

Saludos!!
Título: Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: ~[uNd3rc0d3]~ en 16 Enero 2008, 22:05 PM
aca tiene un programa para guardar su ip en una variable


:: guarda tu ip en la variable "%tuip%"
:: by riva
@echo off
ipconfig /all>tuip.txt
FOR /f "tokens=2 delims=:" %%a in ('find /I " IP" tuip.txt') do (set tuip=%%a)
del tuip.txt


see ya!
Título: Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: carlitos.dll en 12 Mayo 2008, 19:29 PM
[MODIFICADO 5-septiembre-2008]

Mejoras:
-Corregí un pequeño error de la versión 4.5, que no permitía añadir urls que tuviesen el carácter "-"
-Ahora el mensaje de que no se tiene suficientes privilegios, se muestra solamente en el caso de que se detecte tal situación.

Código (dos) [Seleccionar]


::Lock Url 5.1
::by Carlos
::Accepts parameter by the name of a text file with a list of urls

@echo off
setlocal

set FILE=%SystemRoot%\system32\drivers\etc\hosts
set IP=0.0.0.0
set argfile=%~1
set findstr="%WinDir%\system32\findstr.exe"
set find="%WinDir%\system32\find.exe"

:start
call :logo
call :mode
exit

:lock
call :logo
set option=
echo Options:
echo - 1 Add url
echo - 2 Del url
echo - 3 Show urls
echo - 4 Exit
echo.
set /p option=Enter option:
if not defined option (goto lock)
if ["%option%"]==["1"] (goto add)
if ["%option%"]==["2"] (goto del)
if ["%option%"]==["3"] (goto show)
if ["%option%"]==["4"] (goto exit)
goto lock
set option | %find% """" >NUL 2>&1 && goto lock
set option | %find% " " >NUL 2>&1 && goto lock
set option | %findstr% "| & ^ > < # $ ' ` . ; , / \  + - ~ ! ) ( ] [ } { : ? *" >NUL 2>&1 && goto lock
echo %option% | find "=" >NUL 2>&1 && goto lock
if not [{carlitos.dll}]==[{%option%}] (echo off) 2>NUL
if "%errorlevel%"=="9009" (goto lock)
goto lock

:show
type "%FILE%" | %findstr% /b /v "#" | sort | more
pause
goto lock
goto:eof

:del
echo.
set delurl=
set /p delurl="Enter Url to del: "
if not defined delurl (goto del)
set delurl | %find% """" >NUL 2>&1 && goto del
set delurl | %find% " " >NUL 2>&1 && goto del
set delurl | %findstr% "| & ^ > < # $ ' ` ; , \  + ~ ! ) ( ] [ } { ? *" >NUL 2>&1 && goto del
echo %delurl% | find "=" >NUL 2>&1 && goto del
if not [{carlitos.dll}]==[{%delurl%}] (echo off) 2>NUL
if "%errorlevel%"=="9009" (goto del)
goto yesoryes

:yesoryes
echo.
echo You joined address to del: %delurl%
set confirm=
set /p confirm="Is that correct? [y/n/cancel]: "
if not defined confirm (goto yesoryes)
set confirm | %find% """" >NUL 2>&1 && goto yesoryes
set confirm | %find% " " >NUL 2>&1 && goto yesoryes
set confirm | %findstr% "| & ^ > < # $ ' ` . ; , / \  + - ~ ! ) ( ] [ } { : ? *" >NUL 2>&1 && goto yesoryes
echo %confirm% | find "=" >NUL 2>&1 && goto yesoryes
if not [{carlitos.dll}]==[{%confirm%}] (echo off) 2>NUL
if "%errorlevel%"=="9009" (goto yesoryes)
if /i "%confirm%"=="y" (goto find)
if /i "%confirm%"=="n" (goto del)
if /i "%confirm%"=="cancel" (goto lock)
goto yesoryes

:find
type "%FILE%" | %findstr% /i "%delurl%$" >nul && (
cd.>"%FILE%.bak" ||goto message
type "%FILE%" | %findstr% /i /v "%delurl%$">"%FILE%.bak"
del/f/q/a "%FILE%" >nul ||goto message
ren "%FILE%.bak" "hosts" >nul ||goto message
echo The url has been deleted.
) || (echo The url not found.)
pause
goto lock

:add
echo.
set url=
set /p url="Enter Url to add: "
if not defined url (goto add)
set url | %find% """" >NUL 2>&1 && goto add
set url | %find% " " >NUL 2>&1 && goto add
set url | %findstr% "| & ^ > < # $ ' ` ; , \  + ~ ! ) ( ] [ } { ? *" >NUL 2>&1 && goto add
echo %url% | find "=" >NUL 2>&1 && goto add
if not [{carlitos.dll}]==[{%url%}] (echo off) 2>NUL
if "%errorlevel%"=="9009" (goto add)
goto yesorno

:yesorno
echo.
echo You joined address to add: %url%
set confirm=
set /p confirm="Is that correct? [y/n/cancel]: "
if not defined confirm (goto yesorno)
set confirm | %find% """" >NUL 2>&1 && goto yesorno
set confirm | %find% " " >NUL 2>&1 && goto yesorno
set confirm | %findstr% "| & ^ > < # $ ' ` . ; , / \  + - ~ ! ) ( ] [ } { : ? *" >NUL 2>&1 && goto yesorno
echo %confirm% | find "=" >NUL 2>&1 && goto yesorno
if not [{carlitos.dll}]==[{%confirm%}] (echo off) 2>NUL
if "%errorlevel%"=="9009" (goto yesorno)
if /i "%confirm%"=="y" (goto verify_0)
if /i "%confirm%"=="n" (goto add)
if /i "%confirm%"=="cancel" (goto lock)
goto yesorno

:attrib
if not exist "%FILE%" (echo.>>"%FILE%"||goto message)
attrib -r -h -s "%FILE%">NUL||goto message)
goto:eof

:mode
if defined argfile (if exist "%argfile%" (goto argmode))
goto lock
goto:eof

:argmode
for /f %%a in ('type "%argfile%"') do (set url=%%a&call:verify_1&set url=)
goto exit

:verify_0
if /i "%url:~0,4%"=="www." (goto with0)
goto without0

:verify_1
set url | %find% """" >NUL 2>&1 && goto:eof
set url | %find% " " >NUL 2>&1 && goto:eof
set url | %findstr% "| & ^ > < # $ ' ` ; , \  + ~ ! ) ( ] [ } { ? *" >NUL 2>&1 && goto:eof
echo %url% | find "=" >NUL 2>&1 && goto:eof
if not [{carlitos.dll}]==[{%url%}] (echo off) 2>NUL
if "%errorlevel%"=="9009" (goto:eof)
if /i "%url:~0,4%"=="www." (goto with1)
goto without1

goto:eof

:with0
call :with1
goto again

:without0
call :without1
goto again

:with1
call :attrib
echo %IP%    %url:~4%>>"%FILE%"||goto message
echo %IP%    www.%url:~4%>>"%FILE%"||goto message
echo The url has been added.
goto:eof

:without1
call :attrib
echo %IP%    %url%>>"%FILE%"||goto message
echo %IP%    www.%url%>>"%FILE%"||goto message
echo The url has been added.
goto:eof

:again
echo.
set again=
set /p again="Add other url? [y/n]"
if /i "%again%"=="y" (goto add)
if /i "%again%"=="n" (goto lock)
goto again

:logo
cls
echo \--------------------/
echo \ LockUrl v5.1       /
echo \ by Carlos          /
echo \--------------------/
echo.
call:attrib
goto:eof

:message
echo You do not have sufficient privileges.
pause
goto exit

:exit
endlocal
exit

::Lock Url 5.1
::by Carlos
Título: Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: carlitos.dll en 22 Junio 2008, 00:08 AM
Función sleep sin uso de comandos externos



::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::                                                ::::::::
:::::::: FUNCTION SLEEP WITHOUT USING EXTERNAL COMMANDS ::::::::
::::::::                                                ::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::                                                            ::
::  Get a parameter 1% with the number of seconds to wait.    ::
::  Use the following variables: limit cont mirror1 mirror2   ::
::  Use the following variables: SLEEP time increment count   ::
::  $author CarlitoS.dll                                      ::
::                                                            ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@echo off

:SLEEP
if "%1"=="" (goto :eof)
set /a limit=0
set /a limit=%1
if %limit% LEQ 0 (goto :eof)
set /a cont=0
:time
set mirror1=%time:~-4,1%
:increment
set mirror2=%time:~-4,1%
if not %mirror2%==%mirror1% (goto count)
goto increment
:count
set /a cont +=1
if "%cont%"=="%limit%" (goto :eof)
goto time
goto :eof


Título: Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: carlitos.dll en 1 Julio 2008, 21:32 PM


:: DETECTOR OF REMOVABLE DEVICES [V5.0c Final] author Carlitos.dll
:: carlitosdll.blogspot.com
:: Tested in Windows 2000 and XP. Doesn't works in Windows 98 and Me.

@ECHO OFF
IF NOT "%OS%"=="Windows_NT" GOTO Other

ECHO Mounted removable devices detected
ECHO.----------------------------------

VER | FIND "NT"   >NUL && GOTO NT2000
VER | FIND "2000" >NUL && GOTO NT2000

:XPVISTASEVEN
FOR /F "tokens=3 delims=\:" %%A IN ('REG Query HKLM\SYSTEM\MountedDevices ^| FIND "530054004F00520041"') DO (
DIR /A %%A:\ >NUL 2>&1 && ECHO.%%A:
)
PAUSE
GOTO:EOF

:NT2000
START /WAIT REGEDIT /E "%Temp%\devices.dat" "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices"
FOR /F "tokens=3 delims=\:" %%A IN ('TYPE "%Temp%\devices.dat" ^| FINDSTR /R /B /I /C:"\"\\\\DosDevices\\\\[A-Z]:\"=hex:.*,53,00,54,00,4f,00,52,00,41"') DO (
DIR /A %%A:\ >NUL 2>&1 && ECHO.%%A:
)
DEL /F /Q "%Temp%\devices.dat" >NUL 2>&1
PAUSE
GOTO:EOF

:Other
ECHO Current batch is not supported in this Operating System version.


Título: Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: leogtz en 14 Agosto 2008, 02:53 AM
Funcion, Obtener Lenguaje del Sistema Operativo (Testeado en un Windows XP SP2) :
Código (dos) [Seleccionar]

@echo off
for /f "tokens=1 skip=1 delims= " %%x in ('wmic bios get currentlanguage') do (
echo Idioma : %%x
)
pause>nul & goto:eof
Título: Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: SuperDraco en 16 Mayo 2011, 02:10 AM
He echo esté código en 10 minutos para otra persona que lo necesitaba, espero que a alguien más le pueda servir:

Es un registrador de dll's (De 32 bit), nada complicado, lo sé. :P






Código (DOS) [Seleccionar]
REM #### ¿Como usar este Batch?
REM ####
REM #### 1. Colocar el .bat en una carpeta junto a las librerias .dll y .ocx que querais.
REM #### 2. Ejecutar el batch.
REM ####
REM #### Este batch las irá registrando una a una, si se produce algun error os informará.
REM ####
REM #### Tambien puedes llamar a este batch desde otro batch para iniciarlo en otra carpeta, de esta manera:
REM #### Start /Separate .\Carpeta\Registrador.bat
REM #### o
REM #### Registrador.bat Registrame.dll (Sobre archivos que no contengan espacios).

@echo off

Title=Dll/OCX Registrator v1.3 By PiToLoKo para SonyTeam BetaTesters.
Mode con cols=80 lines=20 & color 7
Setlocal enabledelayedexpansion

If %PROCESSOR_ARCHITECTURE%==x86 (goto: 32BIT) ELSE (goto :64BIT)


:32BIT
If exist "%1" goto :PARAMS32BIT
For /f "tokens=*" %%a in ('dir /B %0\..\*.dll; %0\..\*.ocx') do (
Set archivo=%%a
copy /y %0\..\"%%a" "%windir%\system32\" >nul
regsvr32 "%%a" /s
call :error)
goto :END


:64BIT
If exist "%1" goto :PARAMS64BIT
For /f "tokens=*" %%a in ('dir /B %0\..\*.dll; %0\..\*.ocx') do (
Set archivo=%%a
copy /y %0\..\"%%a" "%windir%\syswow64\" >nul
regsvr32 "%windir%\syswow64\%%a" /s
call :error)
goto :END


:ERROR
If %errorlevel% EQU 0 (
echo+ & echo+ !archivo! se ha registrado.
goto:eof
) ELSE (
cls & color c
Echo+ & echo+ ERROR AL INTENTAR REGISTRAR LA DLL "!archivo!", REVISE SU SISTEMA.
Pause >nul
exit)


:PARAMS32BIT
Set archivo=%1
copy /y "%cd%\%1" "%windir%\syswow64\" >nul
regsvr32 "%1" /s
call :error
goto :END


:PARAMS64BIT
Set archivo=%1
copy /y "%cd%\%1" "%windir%\syswow64\" >nul
regsvr32 "%windir%\syswow64\%1" /s
call :error
goto :END


:END
ping -n 3 localhost >nul
cls & color 2
echo+ & echo+ @ Se han instalado todas las librerias correctamente.
ping -n 3 localhost >nul
exit


Título: Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: bITEBUG en 18 Junio 2011, 03:53 AM
COMPARADOR COMPRIMIDOS/CARPETAS

Puede resultar util si como yo nunca borran los archivos comprimidos luego de extraerlos, a menos que se les llene un disco.

Rardel.bat
Código (dos) [Seleccionar]

if %1==/h goto help
rem rardel a estrenar
del extracted.log>nul
del job>nul
del suspects>nul
setlocal enabledelayedexpansion
dir /b %2*>job
for /f "delims=" %%x in (job) do (set query=%%x
set query=!query:+=!
set query=!query: =*!
dir /b "%~1\*!query!*">suspects
dir /b "%~1\*!query!*"
for /f "delims=" %%y in (suspects) do (echo LC "%1%%y" "%~2%%x"
title Comparando "%1%%y" "%~2%%x"...
call lc "%1%%y" "%~2%%x"))
type extracted.log
goto end
:help
echo Rardel junto con lcrar compara archivos rar y carpetas masivamente
echo Rardel [ruta 1] [ruta 2]
ruta 1  ruta de la carpeta que contiene los archivos rar a comparar
ruta 2 ruta de la carpèta que contiene los archivos con los que se desea comparar
:end

(Me han dicho que el numero correcto para comp es 999999999 y no 79999.... pero en mi sistema funciona bien asi como esta, asi que si les da algun pronlema solo cambien el numero luego de "comp=" por 999999999)
Lcrar.bat
Código (dos) [Seleccionar]
@echo off
if %1==h goto help
title Comparando %1 %2...
set registro=%3
if "%3"=="" set registro=extracted.log
SETLOCAL ENABLEDELAYEDEXPANSION
rem a revisar pero aparrentemente funcionando
set interrorlevel=0
set found=
rem extrayendo
if exist "%tmp%\rfc\nowchecking\" rd /s /q "%tmp%\rfc\nowchecking\"
if exist "!tmp!\rfc" rd /s /q "%tmp%\temp\rfc"
md "%tmp%\rfc\muestras\originales"
md "%tmp%\rfc\muestras\copias"
"C:\Archivos de programa\WinRAR\RAR.exe" e -o+ %1 * "%tmp%\rfc\nowchecking\">nul
dir /b /s %2>tubo.rfc
rem creando muestras
rem originales
for %%x in ("%tmp%\nowchecking\*") do (if exist 32l del 32l
copy "%%x" "%%~nx"32l>nul
echo 32l>>"%%~nx"32l
echo n>c
comp /n=799999999999 "%%x" "%%~nx"32l<c>32l
del "%%~nx"32l
for /f "skip=2 tokens=5" %%y in (32l) do set maxlines=%%y
del 32l
del c
rem corregido revision de tags ID3
rem hay que separar casos
set /a baseline=!maxlines!/2
set /a line1=!baseline!+1
set /a line2=!baseline!+2
set /a line3=!baseline!+3
set /a line4=!baseline!+4
set /a lastline=baseline+5
(findstr /n "." "%%x">"!tmp!\%%~nx"pl
rem encontrar linea y volcar: el destino parece incorrecto a como de lugar
rem la ruta de redireccion debe existir
rem el tamaño del archivo no aumentaba porque el volcado estaba sobreescribiendo
findstr "^^!baseline!: ^^!line1!: ^^!line2!: ^^!line3!: ^^!line4!: ^^!lastline!:"  "!tmp!\%%~nx"pl>>"!tmp!\rfc\muestras\originales\%%~nx.lc"
del "!tmp!\%%~nx"pl
)
)

rem copias
for /f "tokens=*" %%x in (tubo.rfc) do (set file=%%x
if exist 32l del 32l
copy "!file!" "!file:~-8,5!"32l>nul
echo 32l>>"!file:~-8,5!"32l
echo n>c
comp /n=799999999999 "!file!" "!file:~-8,5!"32l<c>32l
del "!file:~-8,5!"32l
for /f "skip=2 tokens=5" %%y in (32l) do set maxlines=%%y
del 32l
del c
set /a baseline=!maxlines!/2
set /a line1=!baseline!+1
set /a line2=!baseline!+2
set /a line3=!baseline!+3
set /a line4=!baseline!+4
set /a lastline=!baseline!+5
(findstr /n "." "!file!">"!tmp!\"%%~nx"pl
findstr "^^!baseline!: ^^!line1!: ^^!line2!: ^^!line3!: ^^!line4!: ^^!lastline!:"  "!tmp!\%%~nx"pl>>"!tmp!\rfc\muestras\copias\%%~nx.lc"
del "!tmp!\%%~nx"pl
)
)
rem hasta aqui va bien


REM COMPARANDO MUESTRAS
for %%x in ("!tmp!\rfc\muestras\originales\*") do (
set /a totalfiles=!totalfiles!+1
set found=-1
for %%y in ("!tmp!\rfc\muestras\copias\*") do if not !found!==1 (fc "%%x" "%%y">nul
if !errorlevel!==1 echo ²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
if !errorlevel!==0 echo ²²²²²²²°°°°°°°°°°°°°°°°°°°°°°°°°°°°²²²²²²²²
if !errorlevel!==0 set /a interrorlevel=!interrorlevel!-1
if !errorlevel!==0 set found=1
if not !errorlevel!==0 set found=0
)
)

rd /s /q "!tmp!\rfc"
echo %interrorlevel%/%totalfiles%
set /a rate=%interrorlevel:~1%00/%totalfiles%
echo %rate% %%
rem if %interrorlevel:~1%==%totalfiles%  move %1 %3\%1
if !rate! geq 87 echo %1 %rate% %%>>%registro%
rem casi casi 0k
goto end
:help
echo Lc comparara archivos en el disco duro con sus supuestas imagenes dentro de un archivo rar o zip
echo La sintaxis de lc es la siguiente:
echo Lc [/h] ^<imagen^> ^<carpeta^> ^<archivo de registro^>
echo /h  muestra este texto
echo ^<imagen^>  Ruta completa del archivo rar o zip que se desea comparar
echo ^<carpeta^> Ruta de la carpeta que contiene los archivos con los que se desea comparar
echo ^<archivo de registro^> Archivo que llevara el registro de los archivos comprimidos que coinciden ^(de no especificarse se usara el rachivo por defecto^)
:end


Es un tanto rudo pero funciona bien con menos de 10 archivos si son grandes dependiendo de la cantidad de memoria virtual disponible, lcrar no considera dos archivos iguales (aun). si alguno de los dos o ambos fueron modificados con metadata.

Se que hay metodos mas sofisticados y estoy trabajando en ellos, asi como lograr sortear los tags.
Si alguien considera que se puede mejorar, o sabe de alguna forma de ampliar la memoria virtual puede comentar.
Título: Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: bITEBUG en 18 Junio 2011, 03:59 AM
CONVERTIDOR A BINARIO Y VISCEVERSA


Código (dos) [Seleccionar]
@echo off
if %1==/r goto reciproco

:DIRECTO
:Primitiva
set count=
set binary=

:Aritmetica
set binary=%binary%+I
set /a count=%count%+1
:Axiomatica
set binary=%binary:O+I=I%
set binary=%binary:I+I=+IO%

:Logica
if not %binary:O+I=%==%binary% goto Axiomatica
if not %binary:I+I=%==%binary% goto Axiomatica

:Lenguaje formal
set binary=%binary:+=%

:Recursion
if not %count%==%1 goto aritmetica

:Tesis
set binary=%binary:O=0%
set binary=%binary:I=1%
echo %binary%

goto credits

:RECIPROCO
shift
:_Primitiva
set count=
set binary=%1

:_Hipotesis
set binary=%binary:0=O%
set binary=%binary:1=I%

:_Aritmetica
set binary=%binary%-I


:_Axiomatica
set binary=%binary:O-I=-II%
set binary=%binary:I-I=O%

:_Logica

if not %binary:O-I=%==%binary% goto _Axiomatica
if not %binary:I-I=%==%binary% goto _Axiomatica
set /a count=%count%+1
:_Lenguaje formal
set binary=%binary:-=%

:_Recursion
if not %binary:I=%==%binary% goto _aritmetica

:_Tesis


echo %count%
goto credits



:credits
Título: Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: bITEBUG en 18 Junio 2011, 04:09 AM
TYPE HEXADECIMAL PARA DOS

Código (bash) [Seleccionar]
@echo off
rem dump.bat
setlocal enabledelayedexpansion
set byte=
set offset=
set op1=
set op2=
if %1==/h goto help
if %1==/p (set op1=%1
shift)
if %1==/pp (set op2=%1
shift)
if not exist %1 (
set errorlevel=1
echo no se encuentra el archivo %1
goto end
)
(
Echo;E %~z1 "%~s1"
Echo;D 0 %~z1
Echo;Q
)>d
debug %~s1<d>dmp
del d
if not defined op1 if not defined op2 (type dmp
del dmp
goto end)
if not defined op1 goto op2
for /f "tokens=*" %%x in (dmp) do (set unformatted=%%x
set formatted=!unformatted:   = ; !
echo !formatted!>>dig)
for /f "eol=; tokens=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in (dig) do (set offset=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n
set offset=!offset:;=!
echo !offset:-= !
)
del dmp
del dig
goto end
:op2
for /f "tokens=*" %%x in (dmp) do (set unformatted=%%x
set formatted=!unformatted:   = ; !
echo !formatted!>>dig)
for /f "eol=; tokens=2,3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in (dig) do (set offset=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m
set offset=!offset:;=!
echo !offset:-= !
)
goto end
:Help
echo Muestra el contenido binario de un archivo,
echo.
echo y la sintaxis es la siguiente:
echo Dump ^</p^> ^</pp^> ^<[unidad\ruta\archivo]^>
echo /p Omitira mostrar el texto en ascii
echo /pp Solo mostrara el codigo hexadecimal
:end

del dmp
del dig
:end
set byte=
set offset=
Título: Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: bITEBUG en 24 Junio 2011, 01:31 AM
Un poquito de juego al caso y de paso sentar la base para aplicaciones graficas dentro de un TUI.
A dar volumen a la cosa con un poco de ayuda  del desvirtuado ASCIIart.

Código (bash) [Seleccionar]
Rem Path3D.bat by biTEBUG
@echo off
set a=%2
set b=%3
set c=%4
set d=%5
set e=%6
set f=%7
set g=%8
set switcha=*
set switchb=*
set switchc=*
set switchd=*
set switche=*
set switchf=*
set switchg=*
:ini
set marco=-1
cls
set door=1
set cvisual=1
set lcenter=
set rcenter=.
set horizon=
set fpoint=x
set infarist=/ \
set height=%1
:umbral
set horizon=%horizon%
set /a cvisual=%cvisual%+1
if not %cvisual%==%height% goto umbral


:fuga
if not "%marco%"=="1" ( echo %lcenter:.=^|%\%horizon%%horizon%/%lcenter:.= % ) else ( echo.%lcenter:.=^|%%horizon%.%horizon%/%lcenter:.= %)
set horizon=%horizon:~1%
if "%cvisual%"=="%a%" goto door
if "%cvisual%"=="%b%" goto door
if "%cvisual%"=="%c%" goto door
if "%cvisual%"=="%d%" goto door
if "%cvisual%"=="%e%" goto door
if "%cvisual%"=="%f%" goto door
if "%cvisual%"=="%g%" goto door
goto notdoor
:door
(set /a marco=%marco%*-1
set /a door=%door%*0)
:notdoor
if not "%door%"=="1" (set lcenter=%lcenter%.) else (set lcenter=%lcenter% )
set door=1
set /a cvisual=%cvisual%-1
if not %cvisual%==0 goto fuga
echo %lcenter:.=^|%\%horizon%%horizon%/%lcenter:.= %
:captura

echo %lcenter:.=^|%/%horizon%%horizon%\%lcenter:.= %
set horizon=%horizon%
set lcenter=%lcenter:~,-1%
set /a cvisual=%cvisual%+1
if not %cvisual%==%height% goto captura
if not %cvisual%==%height% goto captura
endlocal
goto forward
if "%a%" gtr "%1" set switcha=/
if "%b%" gtr "%1" set switchb=/
if "%c%" gtr "%1" set switchc=/
if "%d%" gtr "%1" set switchd=/
if "%e%" gtr "%1" set switche=/
if "%f%" gtr "%1" set switchf=/
if "%g%" gtr "%1" set switchg=/
if "%a%"=="1" set switcha=*
if "%b%"=="1" set switchb=*
if "%c%"=="1" set switchc=*
if "%d%"=="1" set switchd=*
if "%e%"=="1" set switche=*
if "%f%"=="1" set switchf=*
if "%g%"=="1" set switchg=*
:if %a% gtr %1 goto stop

if "%a%" gtr "%1" set a=%2
if "%b%" gtr "%1" set b=%3
if "%c%" gtr "%1" set c=%4
echo if "%c%" gtr "%1" set c=%4
if "%d%" gtr "%1" set d=%5
if "%e%" gtr "%1" set e=%6
if "%f%" gtr "%1" set f=%7
if "%g%" gtr "%1" set g=%8
echo if "%c%" gtr "%1" set c=%4
:forward
if defined a set /a a=%a%%switcha%2
if defined b set /a b=%b%%switchb%2
if defined c set /a c=%c%%switchc%2
if defined d set /a d=%d%%switchd%2
if defined e set /a e=%e%%switche%2
if defined f set /a f=%f%%switchf%2
if defined g set /a g=%g%%switchg%2
call wait 2
goto ini
:stop


\                                                / 
  \                                              /   
   \                                            /   
    \                                          /     
     \                                        /     
      \                                      /       
       \                                    /       
        \                                  /         
         \                                /         
          \                              /           
           \                            /           
            \                          /             
             \                        /             
             |           .           /             
             |           .          /               
             | |\                  /                 
             | | \                /                 
             | |  \              /                   
             | |   \            /                   
             | |   |     .     /                   
             | |   ||\        /                     
             | |   || \      /                       
             | |   ||  \    /                       
             | |   ||   \  /                         
             | |   ||    \/                         
             | |   ||    /\                         
             | |   ||   /  \                       
             | |   ||  /    \                       
             | |   || /      \                     
             | |   ||/        \                     
             | |   |/          \                   
             | |   /            \                   
             | |  /              \                 
             | | /                \                 
             | |/                  \               
             | /                    \               
             |/                      \             
             /                        \             
            /                          \           
           /                            \           
          /                              \         
         /                                \         
        /                                  \       
       /                                    \       
      /                                      \     
     /                                        \     
    /                                          \   
   /                                            \   
  /                                              \ 
Título: Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: SuperDraco en 29 Junio 2011, 23:16 PM
Cita de: bITEBUG en 24 Junio 2011, 01:31 AM
Un poquito de juego al caso y de paso sentar la base para aplicaciones graficas dentro de un TUI.
A dar volumen a la cosa con un poco de ayuda  del desvirtuado ASCIIart.

Código (bash) [Seleccionar]
Rem Path3D.bat by biTEBUG
@echo off
set a=%2
set b=%3
set c=%4
set d=%5
set e=%6
set f=%7
set g=%8
set switcha=*
set switchb=*
set switchc=*
set switchd=*
set switche=*
set switchf=*
set switchg=*
:ini
set marco=-1
cls
set door=1
set cvisual=1
set lcenter=
set rcenter=.
set horizon=
set fpoint=x
set infarist=/ \
set height=%1
:umbral
set horizon=%horizon%
set /a cvisual=%cvisual%+1
if not %cvisual%==%height% goto umbral


:fuga
if not "%marco%"=="1" ( echo %lcenter:.=^|%\%horizon%%horizon%/%lcenter:.= % ) else ( echo.%lcenter:.=^|%%horizon%.%horizon%/%lcenter:.= %)
set horizon=%horizon:~1%
if "%cvisual%"=="%a%" goto door
if "%cvisual%"=="%b%" goto door
if "%cvisual%"=="%c%" goto door
if "%cvisual%"=="%d%" goto door
if "%cvisual%"=="%e%" goto door
if "%cvisual%"=="%f%" goto door
if "%cvisual%"=="%g%" goto door
goto notdoor
:door
(set /a marco=%marco%*-1
set /a door=%door%*0)
:notdoor
if not "%door%"=="1" (set lcenter=%lcenter%.) else (set lcenter=%lcenter% )
set door=1
set /a cvisual=%cvisual%-1
if not %cvisual%==0 goto fuga
echo %lcenter:.=^|%\%horizon%%horizon%/%lcenter:.= %
:captura

echo %lcenter:.=^|%/%horizon%%horizon%\%lcenter:.= %
set horizon=%horizon%
set lcenter=%lcenter:~,-1%
set /a cvisual=%cvisual%+1
if not %cvisual%==%height% goto captura
if not %cvisual%==%height% goto captura
endlocal
goto forward
if "%a%" gtr "%1" set switcha=/
if "%b%" gtr "%1" set switchb=/
if "%c%" gtr "%1" set switchc=/
if "%d%" gtr "%1" set switchd=/
if "%e%" gtr "%1" set switche=/
if "%f%" gtr "%1" set switchf=/
if "%g%" gtr "%1" set switchg=/
if "%a%"=="1" set switcha=*
if "%b%"=="1" set switchb=*
if "%c%"=="1" set switchc=*
if "%d%"=="1" set switchd=*
if "%e%"=="1" set switche=*
if "%f%"=="1" set switchf=*
if "%g%"=="1" set switchg=*
:if %a% gtr %1 goto stop

if "%a%" gtr "%1" set a=%2
if "%b%" gtr "%1" set b=%3
if "%c%" gtr "%1" set c=%4
echo if "%c%" gtr "%1" set c=%4
if "%d%" gtr "%1" set d=%5
if "%e%" gtr "%1" set e=%6
if "%f%" gtr "%1" set f=%7
if "%g%" gtr "%1" set g=%8
echo if "%c%" gtr "%1" set c=%4
:forward
if defined a set /a a=%a%%switcha%2
if defined b set /a b=%b%%switchb%2
if defined c set /a c=%c%%switchc%2
if defined d set /a d=%d%%switchd%2
if defined e set /a e=%e%%switche%2
if defined f set /a f=%f%%switchf%2
if defined g set /a g=%g%%switchg%2
call wait 2
goto ini
:stop


\                                                / 
  \                                              /   
   \                                            /   
    \                                          /     
     \                                        /     
      \                                      /       
       \                                    /       
        \                                  /         
         \                                /         
          \                              /           
           \                            /           
            \                          /             
             \                        /             
             |           .           /             
             |           .          /               
             | |\                  /                 
             | | \                /                 
             | |  \              /                   
             | |   \            /                   
             | |   |     .     /                   
             | |   ||\        /                     
             | |   || \      /                       
             | |   ||  \    /                       
             | |   ||   \  /                         
             | |   ||    \/                         
             | |   ||    /\                         
             | |   ||   /  \                       
             | |   ||  /    \                       
             | |   || /      \                     
             | |   ||/        \                     
             | |   |/          \                   
             | |   /            \                   
             | |  /              \                 
             | | /                \                 
             | |/                  \               
             | /                    \               
             |/                      \             
             /                        \             
            /                          \           
           /                            \           
          /                              \         
         /                                \         
        /                                  \       
       /                                    \       
      /                                      \     
     /                                        \     
    /                                          \   
   /                                            \   
  /                                              \ 


Este me ha gustado, mucha imaginación en el code,pero lo he copiado tal cual y no me funciona :/...

saludos
Título: Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
Publicado por: bITEBUG en 6 Julio 2011, 02:10 AM
Cita de: pitoloko en 29 Junio 2011, 23:16 PM
Este me ha gustado, mucha imaginación en el code,pero lo he copiado tal cual y no me funciona :/...

saludos
Recien me hice un tiempo para leer tu mensaje:

Mira no lo he revisado correctamente pero si es la misma version que tengo en mi pc a mi me anda sin problemas.

Si hay un error proba cerrar el bucle con un goto end despues del endlocal.

Decime que entrada le diste.

Se supone que tiene que admitir estos parametros: Art [tamaño en numero de lineas] [<numero de puerta n1> <numero de puerta n2>...]

Art 22 15 13 8 5 crea un diseño de 22 lineas en pantalla una puerta de 3 caracteres en el 8o caracter desde el centro y otra puerta de dos caracteres en el 13o desde el centro.

Es cierto que se me pierden algunas aristas pero el desplazamiento parece correcto

por cierto no se si viste ese "call wait.bat 2" sin ese archivo se temina el proceso abruptamente podes remarcar el comando o hacerte un batch de espera del tipo @ping -w 1000 127.0.0.1>nul