Batch file care utilizeaza comanda PING
In cazul in care dorim sa folosim comanda ping mult mai usor, fara a fi nevoie de repetarea comenzii, putem folosi urmatorul script.
Pasul 1:
Copiem codul de mai jos intr-un editor de text.
@echo off
Title Ping
color 0a
cls
:ping
set /p input=IP/URL:
ping %input%
goto ping
Pasul 2 :
Salvam textul punandu-i orice nume (fara ping) + .bat la sfarsit.
Afisare informatii sistem de operare folosind VBScript
Pasul 1:
Copiem codul de mai jos intr-un editor de text.
Set dtmConvertedDate = CreateObject(“WbemScripting.SWbemDateTime”)
strComputer = “.”
strResults=””
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)
Set colOperatingSystems = objWMIService.ExecQuery _
(“Select * from Win32_OperatingSystem”)
For Each objOperatingSystem in colOperatingSystems
strResults=strResults & objOperatingSystem.Caption & vbCR
strResults=strResults & “Version: ” & objOperatingSystem.Version & vbCR
strResults=strResults & “Product ID: ” & objOperatingSystem.SerialNumber & vbCR
strResults=strResults & “Language: ” & objOperatingSystem.OSLanguage & vbCR
strResults=strResults & “Country code: ” & objOperatingSystem.CountryCode & vbCR
strResults=strResults & “Registered user: ” & objOperatingSystem.RegisteredUser & vbCR
strResults=strResults & “Organization: ” & objOperatingSystem.Organization & vbCR
dtmConvertedDate.Value = objOperatingSystem.InstallDate
dtmInstallDate = dtmConvertedDate.GetVarDate
strResults=strResults & “Date installation: ” & dtmInstallDate & vbCR
Next
MsgBox strResults,64,”OSLang”
Pasul 2:
Salvam textul punandu-i orice nume + .vbs la sfarsit.
Rulam scriptul.
In cazul in care codul nu functioneaza, ar trebui sa inlocuim simbolul ” deoarece site-ul ii schimba formatul.
[mai mult...]Deschidere Task Manager folosing VBScript
Cum putem accesa Task Manager folosing VBScript
Pasul 1 : Copiem urmatorul cod intr-un editor de text
Option Explicit
Dim Application
Application = “%windir%\system32\Taskmgr.exe”
Call RunThis(Application)
Sub RunThis(Application)
Dim Ws,Result
Set Ws = CreateObject(“WScript.Shell”)
Result = Ws.Run(DblQuote(Application),1,False)
End Sub
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
Pasul 2 : Salvam fisierul cu numele dorit, dar sa contina extensia .vbs.
EX : taskmgr.vbs
[mai mult...]Batch file pentru a schimba numele PC-ului
Schimbarea hostname-ului folosind un batch file
Atentie : Acesta trebuie rulat cu drepturi de administrator, altfel nu va functiona !
Pasul 1 : Copiem codul de mai jos intr-un editor de text:
@ECHO OFF
mode con:cols=59 lines=10
echo.
echo Your computer name is [ “%computername%” ]
echo Do you want to change it?
echo.
choice /C YN /N /M “Yes/No->”
goto option-%errorlevel%
:option-1
echo.
set /p input=New name for your computer :
wmic computersystem where name=”%COMPUTERNAME%” call Rename Name=”%input%”
cls
echo.
echo New computer name : “%input%”
set /p RESTART= WOULD YOU LIKE TO RESTART YOUR COMPUTER NOW?(Y/N):
echo.
If /I “%RESTART%”==”Y” (
shutdown.exe /r /t 1
goto shutdown
) else (
echo YOU CHOSE NOT TO RESTART YOUR COMPUTER.
echo.
echo REMEMBER THAT YOU STILL NEED TO RESTART YOUR COMPUTER
echo SO THE CHANGES CAN BE APPLIED!
)
pause
:option-2
pause
Pasul 2 : Salvam fisierul cu orice nume + extensia .bat sau .cmd. EX: shutdown.bat
ATENTIE : Acesta trebuie rulat cu drepturi de administrator! Dupa restart, noul hostname va fi vizibil.
[mai mult...]Deschiderea unei aplicatii cu mesaj de confirmare folosind VBScript
Deschiderea unei aplicatii cu mesaj de confirmare folosind VBScript, un limbaj de scriptare dezvoltat de Microsoft.
Pasul 1 :
Copiem codul de mai jos intr-un editor de text.
Option Explicit
Dim ws,Question,PathProgram
Set ws = CreateObject(“wscript.shell”)
‘change the path of your file
PathProgram = “C:\Program Files\VideoLAN\VLC\vlc.exe”
Question = Msgbox(“Doresti sa deschizi aplicatia VLC?”,VbYesNO + VbQuestion, “VLC”)
If Question = VbYes Then
ws.run DblQuote(PathProgram)
End If
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
Pasul 2 :
Modificam path-ul programului.Ex: C:\Program Files\VideoLAN\VLC\vlc.exe
Putem modifica mesajul de confirmare “Doresti sa deschizi aplicatia VLC?” cu orice alt mesaj.
Putem modifica chiar si titlul casutei, in cazul nostru VLC.
Pasul 3 :
Salvam documentul, punandu-i orice nume + .vbs la sfarsit.
Batch file pentru inchiderea calculatorului cu numaratoare inversa si voce
Urmatorul batch se poate utiliza pentru inchiderea automata a calculatorului. Numaratoarea inversa incepe de la 15 secunde, asistata prin voce.
1. Deschideti notepad sau orice alt editor de text
2. Copiati codul de mai jos:
@echo off
Title Countdown for shutdown
Mode con Cols=67 lines=4 & Color 0A
set /a num=15
:start
echo(
echo Would you like to shutdown your computer in 15 seconds ? (Y/N) ?
Call:Speak “Would you like to shutdown your computer in 15 seconds ?”
set /p “INPUT=”
If /i “%INPUT%” == “y” goto yes
If /i “%INPUT%” == “n” goto no
Exit /b
:yes
cls
echo(
echo Process and Services will be automatically stop after %num% seconds..
Call:Speak “Process and Services will be automatically stop after %num% seconds..”
Goto Countdown
:CountDown
cls
echo(
echo Process and Services will be automatically stop after %num% seconds..
Call:Speak “%num% !”
Timeout /T 1 /NoBreak >nul
set /a num=num-1
if %num% GTR -1 goto :CountDown
goto shutdown
:no
exit
:Speak <msg>
(
echo Set sapi=Createobject(“sapi.spvoice”^)
echo sapi.Speak(“%~1″^)
)>”%tmp%\%~n0.vbs”
Cscript /nologo “%tmp%\%~n0.vbs”
Del “%tmp%\%~n0.vbs”
exit /b
:Shutdown
Call:Speak “We Shutdown the computer !”
shutdown /h
Daca dorim sa modificam timpul. De ex: 4 secundem, modificam urmatoarele:
set /a num=4
echo Would you like to shutdown your computer in 4 seconds ? (Y/N) ?
Call:Speak “Would you like to shutdown your computer in 4 seconds ?”
3. Salvati fisierul cu extensia .bat sau .cmd
4. Il puteti adapta dupa nevoile voastre.
Crearea unui meniu intr-un batch file
1.Deschidem notepad sau orice alt text editor
2.Copiem codul de mai jos
@echo off
:START
cls
echo Choose your option & echo.
echo [I] IPCONFIG
echo [H] HOSTNAME
echo [D] DATE
echo [E] exit
choice /C IHDE /N /M “->”
goto option-%errorlevel%
:option-1 IPCONFIG
echo IPCONFIG
ipconfig
pause
goto start
:option-2 HOSTNAME
echo Hostname
hostname
pause
goto start
:option-3 DATE
echo Date
date /T
pause
goto start
:option-4 EXIT
echo Bye…
goto :EOF
3. Modificam variantele sau tastele pe care dorim sa le apasam
EX : choice /C IHDE /N /M “->”
unde I = option 1, H = option 2, D = option 3, E = option 4
4.Salvam fisierul cu extensia .bat sau .cmd
5.Modificam codul in functie de nevoie.
Deschiderea mai multor link-uri in acelasi timp folosind un batch file si browserul Mozilla
Pentru a putea deschide mai multe link-uri in acelasi timp, puteti folosi codul mentionat mai jos, prin urmatorii pasi.
Pasul 1 : Deschidem un notepad sau orice alt text editor
Pasul 2 : Copiem codul urmator:
@echo off
Set URL=”www.google.com www.yahoo.com www.facebook.com www.twitter.com”
For %%a in (%URL%) Do (Start /d “%programfiles%\Mozilla Firefox” Firefox.exe %Newtab% “%%a”)
Pasul 3 : In Set URL=”introduceti adresele pe care doriti sa le deschideti in acelasi timp”
Pasul 4 : Salvam fisierul cu extensia .bat sau .cmd
[mai mult...]Crearea unui shortcut care sa-ti deschida pagina utilizand Internet Explorer
In cazul in care browserul default nu este Internet Explorer, dar totusi avem nevoie sa deschidem o anumita pagina cu Internet Explorer, putem folosi scriptul de mai jos.
-
- Deschidem notepad sau orice alt text editor.
- Copiem codul de mai jos:
Option Explicit
Dim WS,IE,URL
Set ws = CreateObject(“wscript.shell”)
IE = “%ProgramFiles%\Internet Explorer\iexplore.exe”
URL = “https://askit.ro/solutii/crearea-unui-shortcut-internet-explorer”
WS.run DblQuote(IE) & ” ” & URL
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
3. Inlocuim URL-ul “https://askit.ro/solutii/creearea-unui-shortcut-internet-explorer” cu linkul dorit.
4. Salvam fisierul cu numele-dorit.vbs
5. Accesam fisierul salvat, iar pagina se va deschide automat in Internet Explorer.
[mai mult...]