marcusj0015 Posted September 22, 2010 Share Posted September 22, 2010 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 panellike the HP badge gets installed ONLY on hp machineswmic csproduct get name IF HP==GOTO :HPELSE, Goto :GATEWAYCHECK:GATEWAYCHECKwmic csproduct get name IF Gateway==GOTO :GatewayELSE, Goto :EMACHINESCHECK:EMACHINESCHECKwmic csproduct get name IF eMachine==GOTO :EmachinesELSE, Goto :TOSHIBACHECK:TOSHIBACHECKwmic csproduct get name IF Toshiba==GOTO :ToshibaELSE, Goto :APPLECHECK:APPLECHECKwmic csproduct get name IF Apple==GOTO :AppleELSE, Goto :ACERCHECK:ACERCHECKwmic csproduct get name IF Acer==GOTO :AcerELSE, Goto :ASUSCHECK:ASUSCHECKwmic csproduct get name IF Asus==GOTO :ASUSELSE, 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 More sharing options...
Tripredacus Posted September 22, 2010 Share Posted September 22, 2010 I am not familiar with this method. I have written scripts to read from the DMI via WMI but using VBScript and AutoIT and not a cmd file. Moving to scripting forum. Link to comment Share on other sites More sharing options...
marcusj0015 Posted September 22, 2010 Author Share Posted September 22, 2010 ok thanks for moving it!do you know of any way to check who manufactured the computer the method dosent matter batch powerscript vbscript anything will do as long as it works Link to comment Share on other sites More sharing options...
marcusj0015 Posted September 22, 2010 Author Share Posted September 22, 2010 Using WMI Code Creator i found a way to get what i needBUT 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.ManufacturerNexthow 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 More sharing options...
Tripredacus Posted September 22, 2010 Share Posted September 22, 2010 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 EndIfThis 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 More sharing options...
gunsmokingman Posted September 22, 2010 Share Posted September 22, 2010 (edited) 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 FunctionI took the time to do a quick re-write of the above code.Changes1:\ Added Array To Hold The Manufacture Name2:\ Added A Second Loop Inside The Wmi Querry For ManufactureUsing 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 September 22, 2010 by gunsmokingman Updated Added New Code Link to comment Share on other sites More sharing options...
marcusj0015 Posted September 22, 2010 Author Share Posted September 22, 2010 thanks guys sooo muchi would have had trouble with those other scripts becasue all i really understand is batch scriptsonce again thanks sooo much! Link to comment Share on other sites More sharing options...
Yzöwl Posted September 22, 2010 Share Posted September 22, 2010 Based on your opening post and the fact you said you understand batch scripts, would this do you?@ECHO OFF & SETLOCAL ENABLEEXTENSIONSSET "RP_=%SYSTEMROOT%\OOBE\OEM"FOR /F "SKIP=1 TOKENS=*" %%# IN ( 'WMIC COMPUTERSYSTEM GET MANUFACTURER') DO CALL :SUB %%#PAUSE & GOTO :EOF:SUBIF %1' EQU ' GOTO :EOFIF EXIST "%RP_%\%1\%1.REG" REGEDIT /S "%RP_%\%1\%1.REG" Link to comment Share on other sites More sharing options...
marcusj0015 Posted September 22, 2010 Author Share Posted September 22, 2010 i will try that alsoand see which works besti want to do the script to detect manufacturer during install using SetupComplete.CMdsoill check all these out thanks guys Link to comment Share on other sites More sharing options...
grabben Posted March 27, 2011 Share Posted March 27, 2011 i will try that alsoand see which works besti want to do the script to detect manufacturer during install using SetupComplete.CMdsoill check all these out thanks guysMe 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:asuscopying wallpapers, pictures to right place, run regfile to apply supportinfoI know searchengines script on MDL works excellent but I dont want to copy his script.. Link to comment Share on other sites More sharing options...
Yzöwl Posted March 29, 2011 Share Posted March 29, 2011 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:asuscopying wallpapers, pictures to right place, run regfile to apply supportinfoI 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 More sharing options...
marcusj0015 Posted April 1, 2011 Author Share Posted April 1, 2011 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now