+ Post New Thread
Results 1 to 8 of 8
Scripts Thread, Run script if specific hardware present in Coding and Web Development; Sorry, scripting questions from me again! Is it possible to have a script that does something depending on whether a ...
  1. #1

    Join Date
    Oct 2007
    Location
    Cambridgeshire, UK
    Posts
    306
    Thank Post
    58
    Thanked 23 Times in 20 Posts
    Rep Power
    18

    Run script if specific hardware present

    Sorry, scripting questions from me again!

    Is it possible to have a script that does something depending on whether a specific device is present?

    Basically, (still on my quest for the ultimate, hands-free, go-faster, image deployment sherbang) I have several models of laptop that have either an intel pro/set wireless jobby or the dell wireless equivalent. I currently have to install the relevant software (not drivers as they are already part of the image) post deployment depending on what hardware is present. Can I have a script do this for me and if so, as ever, can anyone point me in the right direction i.e. code?

    I have thought about and had a quick play with the xp zero config malarky but didn't get on very well with stablity etc.

    Thanks,

    Dave.

  2. #2

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,069 Times in 625 Posts
    Rep Power
    740
    As like you state you already have the drivers installed, I would use a specific file from those as a pointer or flag as to whats going to happen next.
    Use some conditional statements and it should be straight forward:

    If file for this wireless chipset exists then
    Do whatever
    Else file for this wireless chipset exists then
    Do whatever
    Endif

  3. #3

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Something like this should work. Add the names of the cards and the commands you want to run in the array; change the "for i= 1 to 2" to the number of cards you're looking for.

    Code:
    On Error Resume Next
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select caption from Win32_NetworkAdapter",,48)
    
    dim sCard(2)
    dim sCommand(2)
    
    sCard(1)="Intel(R) Wireless WiFi Link 4965AGN"
    sCommand(1)="c:\temp\setupintel.exe"
    
    sCard(2)="Some other card name"
    sCommand(2)="c:\temp\othersetup.exe"
    
    bFound=false
    
    For Each objItem in colItems
      for i= 1 to 2
         if instr(objItem.Caption,sCard(i))<>0 then
           bFound=true
           iCard=i
         end if
      next
     Next
    
    if bfound then
      wscript.echo "Found card " & sCard(iCard)
      set oShell=createobject("wscript.shell")
      oshell.run sCommand(iCard)
    else
      wscript.echo "No wireless card found"
    end if

  4. Thanks to srochford from:

    djones (13th March 2008)

  5. #4

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,069 Times in 625 Posts
    Rep Power
    740
    As a real nerdy twist, stick in an error code which pops up a message box if the cards don't exist with the message:

    ' These arenít the cards youíre looking for.... '

    God I need psychiatric help

  6. #5

    Join Date
    Jul 2007
    Location
    Devon
    Posts
    233
    Thank Post
    8
    Thanked 9 Times in 8 Posts
    Rep Power
    16
    Can I just ask what's wrong with the Zero Config Utility?


    If you could obtain an MSI of the stuff you want to install, you can deploy it with a WMI filter attached

  7. #6

    Join Date
    Oct 2007
    Location
    Cambridgeshire, UK
    Posts
    306
    Thank Post
    58
    Thanked 23 Times in 20 Posts
    Rep Power
    18
    Thanks Steve, I'll have a play with that.

    @Lithium: Can I just ask what's wrong with the Zero Config Utility?

    If you could obtain an MSI of the stuff you want to install, you can deploy it with a WMI filter attached
    Only habit I suppose. I've had better performance and fewer niggles in the past with the manufacturer's apps over WZC so for the moment I'd prefer to stick to that. The wireless is working in school with the intel and dell apps and staff are familiar with them for setting up their home wireless details so I'd rather not add that hassle to the pot!

    Plus, I'm (rather oddly) getting into this scripting lark!

    Dave.

  8. #7

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Quote Originally Posted by djones View Post

    Plus, I'm (rather oddly) getting into this scripting lark!

    Dave.
    Nothing odd about that at all :-)

    In fact, I'd go so far as to say that anyone trying to do IT admin on anything more than a couple of PCs is odd if they don't do scripting!

  9. #8

    Join Date
    Dec 2005
    Location
    Essex
    Posts
    85
    Thank Post
    7
    Thanked 5 Times in 5 Posts
    Rep Power
    18
    My first though was to create a GPO that points to run the script on computer startup/shutdown (or how ever you need it) and then use a wmi filter on that GPO for the hardware requirements of your choice.

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 0
    Last Post: 22nd February 2008, 11:26 AM
  2. Replies: 15
    Last Post: 19th September 2007, 10:46 PM
  3. Replies: 9
    Last Post: 10th May 2007, 10:13 AM
  4. Replies: 4
    Last Post: 15th December 2006, 12:14 PM
  5. My Early Christmas Present With Free Poo & Wee!
    By Netman in forum General Chat
    Replies: 20
    Last Post: 13th December 2006, 09:28 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •