You are here:   Home Scripts

Scripts

Oct
28
2008

Detect HALs under WinPE (Vista) by Running Batch Script

E-mail
Written by Misha Hanin   

It’s a lot of posts that explained how to detect HAL. Almost all of those solutions done in VB script. As well I’ve seen a lot of post about “problems’ running VB script under WinPE. So, one day I tried to create a batch file, that allows to detect a HAL under WinPE. I did all my tests under VistaPE 12 (I’ve used the VistaPE v.12 RC1).

Here is content of HAL_Detector.bat script:

@echo off
REM .
REM . - Advanced Configuration and Power Interface (ACPI) PC:  ACPIPIC_UP
REM . - ACPI Uniprocessor PC:                                                 ACPIAPIC_UP
REM . - ACPI Multiprocessor PC:                                               ACPIAPIC_MP
REM .
REM . Advanced Configuration and Power Interface (ACPI) PC
REM . - halacpi.dll (renamed to hal.dll)
REM . - ntkrnlpa.exe
REM . - ntoskrnl.exe
REM .
REM . ACPI Uniprocessor PC
REM . - halaacpi.dll (renamed to hal.dll)
REM . - ntkrnlpa.exe
REM . - ntoskrnl.exe
REM .
REM . ACPI Multiprocessor PC
REM . - halmacpi.dll (renamed to hal.dll)
REM . - ntkrpamp.exe (renamed to ntkrnlpa.exe)
REM . - ntkrnlmp.exe (renamed to ntoskrnl.exe)
REM .
REM ……………….. Explanation About Diferent HAL Versions ………………… ……..
REM .

SETLOCAL
SET PC-HAL=
SET NumberOfLogicalProcessors=
SET New-HAL=

For /F “Tokens=3 Delims= ” %%a in (’REG QUERY HKLM\SYSTEM\CurrentControlSet\Enum\Root\ACPI_HAL000 /v HardwareID’) DO Set PC-HAL=%%a

IF %PC-HAL% == acpipic Set New-HAL=ACPI_Uniprocessor_PC
IF %PC-HAL% == acpiapic (
For /F %%a in (’@WMIC COMPUTERSYSTEM GET NumberOfLogicalProcessors /value^|find “NumberOfLogicalProcessors”‘) do Set %%a
)

IF %NumberOfLogicalProcessors% ==  Set New-HAL=HAL_NOT_DETECTED
IF %NumberOfLogicalProcessors% == 1 Set New-HAL=ACPI_Uniprocessor_PC
IF %NumberOfLogicalProcessors% == 2 Set New-HAL=ACPI_Multiprocessor_PC
IF %NumberOfLogicalProcessors% == 4 Set New-HAL=ACPI_Multiprocessor_PC

@echo Detected HAL: %New-HAL%
@echo Number of Logical Processors: %NumberOfLogicalProcessors%

endlocal

 
Jul
22
2008

Script for Changing the Screen Resolution in Windows Server 2008 Server Core

E-mail
Written by Misha Hanin   

I just finished with a script video_res.bat :). This scripts helps change the screen resolution in Windows Server 2008 Server Core. You can do this manually, but simple use Regedit, but you should know exactly what video driver is working right now in your system, my script does it for you, you just need to select the resolution and that it! Here is a content of video_res.bat:

@ECHO OFF
Rem ****************************************************************
Rem *                                                              *
Rem * Script to change display resolution in Windows 2008 Core     *
Rem *                                                              *
Rem * http://thesystemadministrator.com -  http://www.admininfo.ca *
Rem *                                                              *
Rem ****************************************************************

FOR /F "TOKENS=2 delims={}" %%a in ('"REG QUERY HKLM\SYSTEM\CurrentControlSet\Control\Video /s /f VolatileSettings"') do set VIDEOCARD=%%a

@echo Please select display resolution:

@echo 1 - 640x480
@echo 2 - 800x600
@echo 3 - 1024x768
@echo 4 - 1280x720
@echo 5 - 1280x800
@echo 6 - 1280x1024
@echo 7 - 1440x900
@echo 8 - 1600x1200

SET /P VRES=To set display resolution to 1024x768 type 1 :

IF /i %VRES%==1 REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.XResolution /t REG_DWORD /d 640 /f&REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.YResolution /t REG_DWORD /d 480 /f&goto :EOF
IF /i %VRES%==2 REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.XResolution /t REG_DWORD /d 800 /f&REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.YResolution /t REG_DWORD /d 600 /f&goto :EOF
IF /i %VRES%==3 REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.XResolution /t REG_DWORD /d 1024 /f&REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.YResolution /t REG_DWORD /d 768 /f&goto :EOF
IF /i %VRES%==4 REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.XResolution /t REG_DWORD /d 1280 /f&REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.YResolution /t REG_DWORD /d 720 /f&goto :EOF
IF /i %VRES%==5 REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.XResolution /t REG_DWORD /d 1280 /f&REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.YResolution /t REG_DWORD /d 800 /f&goto :EOF
IF /i %VRES%==6 REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.XResolution /t REG_DWORD /d 1280 /f&REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.YResolution /t REG_DWORD /d 1024 /f&goto :EOF
IF /i %VRES%==7 REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.XResolution /t REG_DWORD /d 1440 /f&REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.YResolution /t REG_DWORD /d 900 /f&goto :EOF
IF /i %VRES%==8 REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.XResolution /t REG_DWORD /d 1600 /f&REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Video\{%VIDEOCARD%}\0000 /v DefaultSettings.YResolution /t REG_DWORD /d 1200 /f&goto :EOF

Remember to Log Off and Log On again ;).

 
Nov
17
2007

Updates: Free Deployment System Scripts

E-mail
Written by Misha Hanin   

I have made a small change in my "Free Deployment System", the set of script allows to deploy, install or run applications on any remote computer.
Equally, I just added a few new lines. In to Config.bat added a new line:

set DSRV= 192.168.211.1

By using a DSRV environment i can set IP or Computer Name of my Deployment Server.
Also, added two new lines to the INSPKG.bat script (Script in original article already changed, so you can simply take a changed script). One of new lines contains following:

%Tools%\psexec.exe \\%RCOMP% -u %USR% -p %PASS% -i cmd /c md C:\Updates

This line creates a directory C:\Updates on remote computer. I use C:\Updates on remote computer to copy there necessary scripts and source of installation programs. The other new line in INSPKG.bat is:

@echo set DSRV=%DSRV%> \\%RCOMP%\C$\updates\config.bat

As you can see, by this line I create a config.bat file on remote computer and put in to environment, that sets a name or IP of our deployment server. Additionally, we need to change a package script. So, after changes, our package script looks like follow:

@echo off
call c:\updates\config.bat
\\%DSRV%\packages\7ZIP\7z442.exe /S

So, now, if we are changed our deployment server, we have not to change our packages script.

 
May
20
2007

Freeware IPA and IPN command line tools makes scripting of local and remote Name/IP and IP/Name conv

E-mail
Written by Misha Hanin   

Downloaf IPINFO.ZIP, unzip it, and store IPA.EXE and IPN.EXE in a folder that is in your PATH.

Prior to having these tools, if I wanted to get my local computer's IP address, I would use a FOR command to parse @ping -n 1 %computername%, or Ipconfig /all.

Now, if I want the my computers IP address, I just parse ipa. If I want the IP address of another computer on my network, I just parse ipa [computername]:

for /f "Tokens=*" %%a in ('ipa SomeComputerName') do set IP=%%a

NOTE: Both IPA.EXE and IPN.EXE return ERRORLEVEL 0 upon success, 1 on an error, and 2 on a syntax error.

If I want to return the computer name associated with an IP address on my network, I just parse ipn [IPAdress]:

for /f  "Tokens=*" %%a in ('ipn SomeIPAaddress') do set name=%%a

NOTE: If the network computer is a member of your domain, the format returned is ComputerName.DomainName, like JSI009.JSIINC.COM. If the network computer is NOT a member of your domain, the NetBIOS computer name is returned, like JSI009. If you always want just the NetBIOS computer name:

for /f  "Tokens=1 Delims=." %%a in ('ipn SomeIPAddress') do set name=%%a
 
May
20
2007

How to find the IP address of the local computer in a logon script or other batch

E-mail
Written by Misha Hanin   

Using only built-in functionality, use the following line to set the IP environment variable:

for /f "skip=1 Tokens=2 Delims=[]" %%i in ('ping -n 1 %computername%') do set ip=%%i

or

for /f "tokens=2 delims=: " %%a in ('nslookup %computername%') do set ip=%%a

 
StartPrev12NextEnd

Page 1 of 2