andyasselin Posted December 9, 2008 Share Posted December 9, 2008 Hi I was wonder if possabley some one Might be able point right direction of script What I wound like to do Is Vb Script that will copy A folder Based on Reslutes Of Wmi Query?strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_BaseBoard",,48) For Each objItem in colItems Wscript.Echo "-----------------------------------" Wscript.Echo "Win32_BaseBoard instance" Wscript.Echo "-----------------------------------" Wscript.Echo "Product: " & objItem.ProductNextgive me the Model number What wound like to do be able to spefic Folder Based on The Diffent Resluts Returned By This queryAny Help or Input Wound Be Greatly Appricated :> Ty In Advanced am not much script guru so am look for Advice Of More Knowledgeable Person Link to comment Share on other sites More sharing options...
Yzöwl Posted December 9, 2008 Share Posted December 9, 2008 What you need is a general If Then Else Statement.strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_BaseBoard",,48)For Each objItem in colItems If objitem.Product = "<SearchString>" Then <Do Something> Else <Do Something different> End IfNext Link to comment Share on other sites More sharing options...
andyasselin Posted December 9, 2008 Author Share Posted December 9, 2008 Hi Yowl Thank for quick reply Please not that my scribt abilty is lacking Correct if am wrong sure am colitem it text string so what you say if get right i just keep put I just put if colitem string for each? so i can listed one by one like right now wmi script has return sting txt say 967ma being mainboard model but on diffent broad say diffent name I can just put if then string strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_BaseBoard",,48)For Each objItem in colItems If objitem.Product = "<SearchString>" Then <Do Something> Else <Do Something different> End IfNextI guess also can just put any vb script code copy file like this exsample i found on I need copy folder from network share include sub foldersSet FSO =CreateObject("scripting.FileSystemObject")FSO.CopyFolder "\\Pta-srv\sjvwebsite\*", "c:\Backup\" ,TrueFSO.CopyFile "\\Pta-srv\sjvwebsite\*", "c:\Backup\", TrueMsgBox"BackUp completed, Goodbye", vbInformation, "Script Informer"something like that ?Anyways Thanks for Quick response Link to comment Share on other sites More sharing options...
gunsmokingman Posted December 9, 2008 Share Posted December 9, 2008 If you want to copy and have a diplay on it progress then something like this would be better. This will copy the source folder and all of it contents, with a diplay of progress. Dim Shl :Set Shl = CreateObject("Shell.Application") Dim Folder, Source, Target Source = "\\COMPUTER_NAME_OR _IP\FOLDER_NAME\COPY_THIS_FOLDER" Target = "E:\FOLDER_NAME" Set Folder = Shl.NameSpace(Target) Folder.CopyHere Source Link to comment Share on other sites More sharing options...
andyasselin Posted December 9, 2008 Author Share Posted December 9, 2008 strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_BaseBoard",,48)For Each objItem in colItems If objitem.Product = "776295U" ThenDim Shl :Set Shl = CreateObject("Shell.Application")Dim Folder, Source, Target Source = "\\COMPUTER_NAME_OR _IP\FOLDER_NAME\COPY_THIS_FOLDER" Target = "E:\FOLDER_NAME" Set Folder = Shl.NameSpace(Target) Folder.CopyHere Source Else Wscript.Echo "Product: " & objItem.Product End IfNextis this remotely right? i know need change folder Link to comment Share on other sites More sharing options...
gunsmokingman Posted December 9, 2008 Share Posted December 9, 2008 Just set the target and source to what you need. Link to comment Share on other sites More sharing options...
andyasselin Posted December 18, 2008 Author Share Posted December 18, 2008 Hi i got some of it figure out copy file part based on broad i if = statement going?seem be have troblue get second this what got so far how wound anythey if product = fm10 or diffent id ?????? i try few way but i can,nt seem to get it maybe i need else or next statement ? Thank all in advnaced i got some of work out strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_BaseBoard",,48)For Each objItem in colItems If objitem.Product = "440BX Desktop Reference Platform" Then Set FSO =CreateObject("scripting.FileSystemObject") FSO.CopyFolder "\\Server\installshare\drivers\VMWARE\*", "c:\DRIVERS\" ,True Else MsgBox "I don't know what mainboard this is no driverse will be copyed you must manual install" End IfNext Link to comment Share on other sites More sharing options...
gunsmokingman Posted December 18, 2008 Share Posted December 18, 2008 Perhaps try this script.Dim ChkItem, colItems, FSO, objItem, objWMIService, StrItem, StrResult strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")'-> Array To Hold The Items StrItem = Array( _ "Benicia", _ "440BX Desktop Reference Platform", _ "ANOTHER BASEBOARD1", _ "ANOTHER BASEBOARD2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BaseBoard",,48) For Each objItem in colItems For Each ChkItem In StrItem If InStr(LCase(objitem.Product), LCase(ChkItem))Then StrResult = objitem.Product End If Next Next If Len(StrResult) >= 1 Then Set FSO =CreateObject("scripting.FileSystemObject") MsgBox "Found This Match " & StrResult FSO.CopyFolder "\\Server\installshare\drivers\VMWARE\*", "c:\DRIVERS\" ,True Else MsgBox "There is no match in the list" End If Link to comment Share on other sites More sharing options...
andyasselin Posted December 19, 2008 Author Share Posted December 19, 2008 (edited) Hi Gunsmokeinman :> i see you Vancouver am from vancouver island I was wonder if you maybe give me exsample with two item already in it?I can seem to graspe what i am missing I am guess the number beside broad name? is identify for item and that If Len(StrResult) >= 1 Then Set FSO =CreateObject("scripting.FileSystemObject") MsgBox "Found This Match " & StrResult FSO.CopyFolder "\\Server\installshare\drivers\VMWARE\*", "c:\DRIVERS\" ,True Elseand this wound be line it run if want to do more wound just add that twice and change number to diffent broad id?I hope not bug Thank for reply just try get idea behind this am not super script guy Thank For input so far my question do also need else statment for if not right model or cound just have one if not found it say it once so script does.nt need line for each item that not in listedmaybe am missing something does script you have do one item based more one broadid I need to do diffent things base on id is found Edited December 19, 2008 by andyasselin Link to comment Share on other sites More sharing options...
gunsmokingman Posted December 19, 2008 Share Posted December 19, 2008 The Array hold a list of MB I used mine the one you posted and 2 Made Up OnesStrItem = Array( _ "Benicia", _ "440BX Desktop Reference Platform", _ "ANOTHER BASEBOARD1", _ "ANOTHER BASEBOARD2")It Then Starts The WMI Querry and Then Anther Loop To Compares Strings From The StrItem Array 'Loop One WMI For Each objItem in colItems 'Loop 2 StrItem Array For Each ChkItem In StrItem 'Compare The String If InStr(LCase(objitem.Product), LCase(ChkItem))Then StrResult = objitem.Product End If Next NextThis is to check if the querry came back with a result. It checks the lengh of StrReults if it over 1character then it will produce Found This Match And The Match Object. The Else means StrResultcame back with less then 1 character, or No Match was found in the Array. If Len(StrResult) >= 1 Then Set FSO =CreateObject("scripting.FileSystemObject") MsgBox "Found This Match " & StrResult FSO.CopyFolder "\\Server\installshare\drivers\VMWARE\*", "c:\DRIVERS\" ,True Else MsgBox "There is no match in the list" End If Link to comment Share on other sites More sharing options...
andyasselin Posted December 24, 2008 Author Share Posted December 24, 2008 I think am go crazy with this okay so you say each array get number like one 1 2 3 etc??or does it use name like id broad to ideinfty arraw then i change the string If Len(StrResult) >= 2 Then to the number or broad name ? right now script work one broad but second one does seem to copy or try to copy same folder from fristed oneDim ChkItem, colItems, FSO, objItem, objWMIService, StrItem, StrResultstrComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")'-> Array To Hold The Items StrItem = Array( _ "Benicia", _ "776295U", _ "ANOTHER BASEBOARD1", _ "ANOTHER BASEBOARD2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BaseBoard",,48) For Each objItem in colItems For Each ChkItem In StrItem If InStr(LCase(objitem.Product), LCase(ChkItem))Then StrResult = objitem.Product End If Next Next If Len(StrResult) >= 2 Then Set FSO =CreateObject("scripting.FileSystemObject") MsgBox "Found This Match " & StrResult FSO.CopyFolder "\\Server\installshare\drivers\VMWARE\*", "c:\DRIVERS\" ,True Else MsgBox "There is no match in the list" End If If Len(StrResult) >= 3 Then Set FSO =CreateObject("scripting.FileSystemObject") MsgBox "Found This Match " & StrResult FSO.CopyFolder "\\Server\installshare\drivers\VMWARE\*", "c:\DRIVERS\" ,True Else MsgBox "There is no match in the list" End If Link to comment Share on other sites More sharing options...
gunsmokingman Posted December 24, 2008 Share Posted December 24, 2008 The script will only match one baseboard at a time. If you wanted to match multiple boards then you would needanother Array that would hold a list of computer you would want to connect to then compare the Array of theBaseboards. Link to comment Share on other sites More sharing options...
andyasselin Posted December 24, 2008 Author Share Posted December 24, 2008 okay so i wound,nt need diffent script or mode to my exist one i got any suggestion on mode for current one it works only issues not sure what format look for second model broad maybe it not like your only able handled one 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