Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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.

 

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

  • Thanks 1
Posted

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 :eek:

Posted

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 :)

Posted

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.

Posted

 

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!

Posted
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.

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



×
×
  • Create New...