elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Ingresar Registrarse
08 Septiembre 2008, 14:00  



+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Scripting
| | | |-+  Librería de funciones y scripts BATCH Actualizado 26/05/07
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Imprimir
Autor Tema: Librería de funciones y scripts BATCH Actualizado 26/05/07  (Leído 6451 veces)
ne0x

Desconectado Desconectado

Mensajes: 270



Ver Perfil
Librería de funciones y scripts BATCH Actualizado 26/05/07
« en: 27 Abril 2007, 14:19 »

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:


 
Código:
: 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:

Código:
    @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

Código:

    @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

Código:
    @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:

Código:
:: 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


Código:
:: 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


Código:
:: 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
)
)

Código:
:: 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

Código:
:: 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


Código:

:: 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:

Código:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: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:

Código:
:: 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:

Código:
:: 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


Código:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: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:

Código:
:: 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

Código:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: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

Código:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: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

Código:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: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

Código:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: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

Código:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: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


Código:
@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

Código:
@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

Código:
@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

Código:
:: 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


Código:
@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

Código:
:: 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
« Última modificación: 14 Agosto 2008, 22:48 por sirdarckcat » En línea

sirdarckcat
sdc
CoAdmin
*****
Desconectado Desconectado

Mensajes: 4.523


HAND


Ver Perfil WWW
Funcion de DEC2HEX en batch
« Respuesta #1 en: 02 Octubre 2007, 07:53 »

Lo hice para otro programa, pero les podría servir..
Código
: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!!
« Última modificación: 02 Octubre 2007, 07:55 por sirdarckcat » En línea

~[uNd3rc0d3]~

Desconectado Desconectado

Mensajes: 133


programando...


Ver Perfil
Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
« Respuesta #2 en: 16 Enero 2008, 22:05 »

aca tiene un programa para guardar su ip en una variable

Código:
:: 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!
En línea


leete las reglas asi todos estamos mejor ;)
carlitos.dll

Desconectado Desconectado

Mensajes: 252


Ver Perfil
Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
« Respuesta #3 en: 12 Mayo 2008, 19:29 »

[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
 
::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
 
« Última modificación: 05 Septiembre 2008, 19:35 por c.a.r.l.o.s. » En línea
carlitos.dll

Desconectado Desconectado

Mensajes: 252


Ver Perfil
Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
« Respuesta #4 en: 22 Junio 2008, 00:08 »

Función sleep sin uso de comandos externos

Código:

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::                                                ::::::::
:::::::: 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

« Última modificación: 24 Julio 2008, 01:40 por carlitos.dll » En línea
carlitos.dll

Desconectado Desconectado

Mensajes: 252


Ver Perfil
Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
« Respuesta #5 en: 01 Julio 2008, 21:32 »

Código:

:: 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.

« Última modificación: 05 Septiembre 2008, 06:11 por c.a.r.l.o.s. » En línea
RockoX

Desconectado Desconectado

Mensajes: 273


... L30 ...


Ver Perfil
Re: Librería de funciones y scripts BATCH Actualizado 26/05/07
« Respuesta #6 en: 14 Agosto 2008, 02:53 »

Funcion, Obtener Lenguaje del Sistema Operativo (Testeado en un Windows XP SP2) :
Código
@echo off
for /f "tokens=1 skip=1 delims= " %%x in ('wmic bios get currentlanguage') do (
echo Idioma : %%x
)
pause>nul & goto:eof
En línea

Yo tocando Canon Rock (Guitarra Electrica)...   
http://youtube.com/watch?v=xZx7DEweeKw
Páginas: [1] Ir Arriba Imprimir 
Ir a:  







Consolas     La Web de Goku     MilW0rm     MundoDivx

Hispabyte     Truzone     TodoReviews     ZonaPhotoshop

hard-h2o modding    Foros de ayuda    Yashira.org    Videojuegos    indetectables.net   

Noticias Informatica