Jump to content

Script To Detect Computer Manufacturer?


Recommended Posts

im trying to write a script to detect which computer manufacturer made the computer Windows 7 is being installed upon

(i need to have 1 DVD per archeticture because i have 4 pcs that are always getting f***ed up somehow)

can anyone test this script?

and if something is wrong can you help me correct the problem?

BTW This script is for installing the correct OEM info for the control panel

like the HP badge gets installed ONLY on hp machines

wmic csproduct get name IF HP==GOTO :HP

ELSE, Goto :GATEWAYCHECK

:GATEWAYCHECK

wmic csproduct get name IF Gateway==GOTO :Gateway

ELSE, Goto :EMACHINESCHECK

:EMACHINESCHECK

wmic csproduct get name IF eMachine==GOTO :Emachines

ELSE, Goto :TOSHIBACHECK

:TOSHIBACHECK

wmic csproduct get name IF Toshiba==GOTO :Toshiba

ELSE, Goto :APPLECHECK

:APPLECHECK

wmic csproduct get name IF Apple==GOTO :Apple

ELSE, Goto :ACERCHECK

:ACERCHECK

wmic csproduct get name IF Acer==GOTO :Acer

ELSE, Goto :ASUSCHECK

:ASUSCHECK

wmic csproduct get name IF Asus==GOTO :ASUS

ELSE, Goto :ASUSCHECK

:HP

%Systemroot%\OOBE\OEM\HP\HP.Reg

:Gateway

%Systemroot%\OOBE\OEM\Gateway\Gateway.Reg

:Emachines

%Systemroot%\OOBE\OEM\Emachine\Emachines.Reg

:Toshiba

%Systemroot%\OOBE\OEM\Toshiba\Toshiba.Reg

:Apple

%Systemroot%\OOBE\OEM\Apple\Apple.Reg

Link to comment
Share on other sites


Using WMI Code Creator i found a way to get what i need

BUT i dont know what else to do

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")

Set colItems = objWMIService.ExecQuery( _

"SELECT * FROM Win32_BIOS",,48)

For Each objItem in colItems

Wscript.Echo "-----------------------------------"

Wscript.Echo "Win32_BIOS instance"

Wscript.Echo "-----------------------------------"

Wscript.Echo "Manufacturer: " & objItem.Manufacturer

Next

how do i make it scan the manufacturer then if its HP it go to hp and execute the hp commands and if not hp scan sagin and check for gateway and so on and so forth?

Link to comment
Share on other sites

You'd have to test this. i do not know if this works. I adapted your code into an existing AutoIT script I made to pull different info.

#include <file.au3>
Global $sWMIService, $objWMIService, $colItems, $sName, $oItem
$sWMIService = "winmgmts:\\" & @ComputerName & "\root\CIMV2"
$objWMIService = ObjGet($sWMIService)
IF IsObj($objWMIService) Then
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS")
If IsObj($colItems) Then
For $oItem In $colItems
$sName = $oItem.Manufacturer
Next
EndIf

This is an incomplete function. This code doesn't do anything but get the Manufacturer and store it as a variable $sName. I also just declared everything a global. Probably don't need everything but $sName needs to be a global in order for the rest of the script to access it.

So now that you have your result stored in $sName, you could verify it with this:

MsgBox(64, "Win32_BIOS Item", "manufacturer = " & $sModel)

So then now you have this as a global variable, you can do other things with it besides show it in a messagebox. While you can do the multiple IF/Then statements, you should probably use a Switch statement instead.

Link to comment
Share on other sites

Here try this VBS Script, it should do what you wanted.

I tested this so it has no runtime errors.

Save As OemReg.vbs


'-> Varibles And Objects
Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Wmi :Set Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Dim Obj, Reg
Reg = Act.ExpandEnvironmentStrings("%Systemroot%\OOBE\OEM\")
'-> Wmi Querry For Computer Manufacture
For Each Obj In Wmi.ExecQuery("SELECT * FROM Win32_ComputerSystem")
If InStr(1,Obj.Manufacturer,"Acer",1) Then
RegFileAdd("Acer")
ElseIf InStr(1,Obj.Manufacturer,"Apple",1) Then
RegFileAdd("Apple")
ElseIf InStr(1,Obj.Manufacturer,"ASUS",1) Then
RegFileAdd("ASUS")
ElseIf InStr(1,Obj.Manufacturer,"eMachine",1) Then
RegFileAdd("eMachine")
ElseIf InStr(1,Obj.Manufacturer,"Gateway",1) Then
RegFileAdd("Gateway")
ElseIf InStr(1,Obj.Manufacturer,"HP",1) Then
RegFileAdd("HP")
ElseIf InStr(1,Obj.Manufacturer,"Toshiba",1) Then
RegFileAdd("Toshiba")
Else
MsgBox "Can Not Determine The Computer Model", 4128,"Undetermine Computer Model"
End If
Next
'-> Function To Add The Registry File
Function RegFileAdd(Name)
Reg = Reg & Name & "\" & Name & ".reg"
If Fso.FileExists(Reg) Then
Act.Run("Regedit /S " & Reg),1,True
Else
MsgBox "Error Can Not Find This File" & vbCrLf & _
Reg, 4128,"Reg File Missing"
End If
End Function

I took the time to do a quick re-write of the above code.

Changes

1:\ Added Array To Hold The Manufacture Name

2:\ Added A Second Loop Inside The Wmi Querry For Manufacture

Using The Array For Reference.


'-> Varibles And Objects
Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Wmi :Set Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Dim Chk, Col, I, Obj, Reg
Chk = False
Reg = Act.ExpandEnvironmentStrings("%Systemroot%\OOBE\OEM\")
'-> Array To Hold Manufacture Name
Col = Array("Acer","Apple","ASUS","eMachine","Gateway", "HP", "Toshiba")
'-> Wmi Querry For Computer Manufacture
For Each Obj In Wmi.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each I In Col
If InStr(1,Obj.Manufacturer,I,1) Then
RegFileAdd(I)
Chk = True
End If
Next
Next
'-> If There Was No Matching Manufacture
If Chk = False Then
MsgBox "Can Not Determine The Computer Model", 4128,"Undetermine Computer Model"
End If
'-> Function To Add The Registry File
Function RegFileAdd(Name)
Reg = Reg & Name & "\" & Name & ".reg"
If Fso.FileExists(Reg) Then
Act.Run("Regedit /S " & Reg),1,True
Else
MsgBox "Error Can Not Find This File" & vbCrLf & _
Reg, 4128,"Reg File Missing"
End If
End Function

Edited by gunsmokingman
Updated Added New Code
Link to comment
Share on other sites

Based on your opening post and the fact you said you understand batch scripts, would this do you?

@ECHO OFF & SETLOCAL ENABLEEXTENSIONS
SET "RP_=%SYSTEMROOT%\OOBE\OEM"
FOR /F "SKIP=1 TOKENS=*" %%# IN (
'WMIC COMPUTERSYSTEM GET MANUFACTURER') DO CALL :SUB %%#
PAUSE & GOTO :EOF
:SUB
IF %1' EQU ' GOTO :EOF
IF EXIST "%RP_%\%1\%1.REG" REGEDIT /S "%RP_%\%1\%1.REG"

Link to comment
Share on other sites

  • 6 months later...

i will try that also

and see which works best

i want to do the script to detect manufacturer during install using SetupComplete.CMd

soill check all these out thanks guys

Me too, actually. Sorry for bringing this up again hehe.

Im trying to make an OOBE script that uses WMIC, finds manufacturer and sets OEM branding, user account pictures, wallpapers etc.

If asus (for example) goto asus

:asus

copying wallpapers, pictures to right place, run regfile to apply supportinfo

I know searchengines script on MDL works excellent but I dont want to copy his script..

Link to comment
Share on other sites

Im trying to make an OOBE script that uses WMIC, finds manufacturer and sets OEM branding, user account pictures, wallpapers etc.

If asus (for example) goto asus

:asus

copying wallpapers, pictures to right place, run regfile to apply supportinfo

I know searchengines script on MDL works excellent but I dont want to copy his script..

Are you serious?

You are trying to make a script, (obviously without success) and you are not providing us with any of it in order to prompt us for the help you need. Someone else has already provided an 'excellent' script and instead of using it you'd prefer one of us to do it for you instead!

On top of that, the main part of what you need is already provided in this topic.

Link to comment
Share on other sites

grabben, why do you think i asked for a script to detect computer manufactorur and model number?

FOR EXACTLY WHAT YOU JUST SAID, TAKE THE **** SCRIPT AND CUSTOMIZE IT FOR YOUR NEEDS, if you have a problem, post a thread, but don't ask everyone else do the work for you, your a n00b, that's fine, but your lazy, that's NOT fine

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...