Category Archives: Windows

Last reboot time

Make a vbs file with this and run it :

strComputer = “.”
set objWMIDateTime = CreateObject(“WbemScripting.SWbemDateTime”)
set objWMI = GetObject(“winmgmts:” & strComputer & “rootcimv2”)
set colOS = objWMI.InstancesOf(“Win32_OperatingSystem”)
for each objOS in colOS
objWMIDateTime.Value = objOS.LastBootUpTime
Wscript.Echo “Reboot time: ” & objWMIDateTime.GetVarDate
next

Install SNMP with script

To install SNTP with a script create 2 files:

  • Start.bat
  • snmp.txt

In start.bat put :

copy SNMP.txt %SYSTEMDRIVE%

%windir%system32sysocmgr.exe /i:%windir%infsysoc.inf /u:%SYSTEMDRIVE%SNMP.txt /r

in snmp.txt put :

[NetOptionalComponents]
SNMP = 1

After this run start.bat on the machine

Activate Windows

To easy activate Windows you can make a bat file with this (you only have to put in the keys)

@echo off

REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “EditionID” | FINDSTR /I SERVERSTANDARD
IF NOT ERRORLEVEL 1 SET PROD=SERVERSTANDARD
REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “EditionID” | FINDSTR /I SERVERENTERPRISE
IF NOT ERRORLEVEL 1 SET PROD=SERVERENTERPRISE
REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “ProductName” | findstr /I DATACENTER
IF NOT ERRORLEVEL 1 SET PROD=DATACENTER
REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “ProductName” | findstr /I “Web”
IF NOT ERRORLEVEL 1 SET PROD=WEBSERVER

REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “ProductName” | findstr /I R2
IF NOT ERRORLEVEL 1 ( SET PROD=%PROD%R2) else ( SET PROD=%PROD%R0)

REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “ProductName” | findstr /I 2008
IF NOT ERRORLEVEL 1 SET PROD=%PROD%2008
REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “ProductName” | findstr /I “2012”
IF NOT ERRORLEVEL 1 SET PROD=%PROD%2012
REG QUERY “HKLMSOFTWAREMicrosoftWindows NTCurrentVersion” /v “ProductName” | findstr /I “7”
IF NOT ERRORLEVEL 1 SET PROD=7

IF %PROD%==SERVERSTANDARDR02008 SET PIDKEY=
IF %PROD%==SERVERENTERPRISER02008 SET PIDKEY=
IF %PROD%==DATACENTERR02008 SET PIDKEY=
IF %PROD%==WEBSERVERR02008 SET PIDKEY=
IF %PROD%==SERVERSTANDARDR22008 SET PIDKEY=
IF %PROD%==SERVERENTERPRISER22008 SET PIDKEY=
IF %PROD%==DATACENTERR22008 SET PIDKEY=XBWXK-
IF %PROD%==WEBSERVERR22008 SET PIDKEY=
IF %PROD%==SERVERSTANDARDR02012 SET PIDKEY=
IF %PROD%==DATACENTERR02012 SET PIDKEY=
IF %PROD%==7 SET PIDKEY=

cscript %windir%System32slmgr.vbs -ipk %PIDKEY%
cscript %windir%System32slmgr.vbs -ato

Windows 2003 R2 slow install

If the msiexec.exe uses 13 % CPU and the uninstall /install is slow the problem is in the registration database.

Delete these keys :

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\Install\RefHive\Hewlett-Packard]
[HKEY_USERS\.DEFAULT\Software\Hewlett-Packard]

REMEMBER TO BACK YOUR REGISTRY UP BEFORE MAKING CHANGES TO IT!

Why:
All the extra info in the registry was being read and written to a backup of the registry during software installs, taking a really long time.

Deleting these keys and their subkeys fixed the trouble.

Create bootable USB

1. Prepare the USB stick thru diskpart

SELECT DISK 1 (use LIST DISK to find out which disk is your USB stick)CLEAN

CREATE PARTITION PRIMARY

SELECT PARTITION 1

ACTIVE

FORMAT FS=NTFS QUICK

ASSIGN

EXIT

2. Mount the Windows install DVD and find this folder “boot”

3. Run this command from a CMD (in the “boot” folder)

BOOTSECT.EXE /NT60 H: (Where H: is your USB stick)

4. Copy all the files from your Windows install DVD to your USB stick