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 ...
-
13th March 2008, 09:10 PM #1
- Rep Power
- 13
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.
-
-
IDG Tech News
-
13th March 2008, 10:35 PM #2 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
-
-
13th March 2008, 10:38 PM #3 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
-
Thanks to srochford from:
-
13th March 2008, 10:52 PM #4 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
-
-
13th March 2008, 11:11 PM #5
- Rep Power
- 11
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
-
-
14th March 2008, 12:00 AM #6
- Rep Power
- 13
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.
-
-
14th March 2008, 01:02 PM #7 
Originally Posted by
djones
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!
-
-
14th March 2008, 04:50 PM #8
- Rep Power
- 14
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:
Similar Threads
-
By ZeroHour in forum Scripts
Replies: 0
Last Post: 22nd February 2008, 12:26 PM
-
By timbo343 in forum Scripts
Replies: 15
Last Post: 19th September 2007, 10:46 PM
-
By sidewinder in forum Scripts
Replies: 9
Last Post: 10th May 2007, 10:13 AM
-
By sidewinder in forum Windows
Replies: 4
Last Post: 15th December 2006, 01:14 PM
-
By Netman in forum General Chat
Replies: 20
Last Post: 13th December 2006, 10: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
-
Forum Rules