Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Monday, 20 January 2014

[CMD] Safe to Rearm Script Windows 7, Server 2008 R2

No comments:
Rearm to extend up to 50 days more
Assalamualaikom w.b.t

After prepared about 25 desktop with windows server 2008 R2, i need a simple batch command that can exteding the trial version without wasting available rearm count. In windows 7 and windows server 2008 r2, we can rearm or extend the trial days five times with 10 days each by execute this command in command prompt:

slmgr.vbs /rearm

However if we execute multiple times, the remaining rearm count will decreased and overwrites and lastly will left to zero. This will wasting our remaining rearm availability that should be execute after each 10 days trial for five times.

Execte slmgr.vbs /dlv to view remainign time and rearm count


Then, i got an idea to create simple basic tool using batch command that can rearm without worrying about its still under trial days. This script will rearm if our trial lest than 8 hours to become expired.

Here you go:

@echo off
cls
mode con: cols=65 lines=15
:START
echo. ---- Safe Autorearm build to avoid wasting remaining rearm ----
echo.         Created by myskali.blogspot.com
echo.               Associate Technical Services
echo.               last updated 14 January 2014
echo.
echo. Finding available minutes...
echo.

for /f "tokens=3" %%a in ('cscript.exe %windir%\system32\slmgr.vbs /dlv ^| FINDSTR /i /c:"Notification Reason"') do goto REARM

for /f "tokens=3" %%a in ('cscript.exe %windir%\system32\slmgr.vbs /dlv ^| FINDSTR /i /c:"Time Remaining"') do set dtime=%%a


echo.
echo. ++   Minutes remaining is %dtime%   ++


if %dtime% GEQ 500 goto BANYAK
goto REARM



:BANYAK
echo.
echo.
echo. Your current rearm still have much time to be used!
echo.
echo.
goto EXIT

:REARM
echo.
echo.
echo+
cscript.exe %windir%\system32\slmgr.vbs /rearm
IF ERRORLEVEL 1 pause & goto START
shutdown /r /t 30 /C "Windows will restart in 30 seconds..."
echo+
goto EXIT

:EXIT
pause
exit


Copy above command and save as saferearm.bat and ready to use.


Sunday, 12 January 2014

[VBS] Menggubah Nama Komputer Dengan Serial Number Dari Bios

No comments:
Assalamualaikom w.b.t

Bulan Januari 2014 merupakan bulan yang sibuk kerana saya ditugaskan untuk mempersiapkan komputer-komputer untuk digunakan di makmal dan diserahkan kepada staf-staf.

Antara tugasannya ialah menukar nama komputer dengan nombor siri DELL. Nombor siri DELL biasanya dikenali sebagai Servis Tag. Servis Tag ini terdiri daripada 7 aksara dan dalam bentuk asas 36 (0-9, A-Z). Produk OEM jenama DELL juga memiliki Ekspress Code yang sebenarnya merupakan penukaran kepada asas 10 (0-9) dari Service Tag.

Untuk memudahkan kerja-kerja ketika proses membuat installasi perision-perisian wajib saya telah menyiapkan skrip vbs untuk menukar nama komputer lama ke nama komputer berdasarkan Service Tag. Secara khusunya saya mahukan apabila script ini dijalankan ia akan menukar nama komputer dengan format seperti ini:

SCALE_B1YSUJS (yg warna merah ada nombor siri komputer atau Dell Service Tag)

Berikut skripnya yg perlu disimpan sebagai fail dengan extension .vbs:

dim Bios, BiosSerial

'get serial number
for each Bios in GetObject("winmgmts:").InstancesOf ("win32_bios")
BiosSerial = Bios.SerialNumber
exit for
next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colComputers
err = objComputer.Rename("SCALE_" + BiosSerial)
Next

'messagebox
If err = 0 Then
msgbox "Computername changed to " + BiosSerial + "...", yes
Else
MsgBox "Error code: " & err
End If