/build/static/layout/Breadcrumb_cap_w.png

Scripting problem

Hi!
First time I post here (woho!)
I am going to cut to the chase:
One .bat file is calling for this script and if this script succeeds it would then execute another .bat file to initiate the installation.
I know this seems complicated, but I can't do anything about that. It is how it is supposed to be done :/
This is how far I have gotten for the moment, I am now stuck.
It seems like the script will only provide the computer information and not the display driver(s).
It's like it will never even execute the display driver section.
Now the first .bat file is working, I have not gotten as far as the second .bat file, because I am stuck on this one.
Any tips or help is appreciated.

Here is the script.

On Error Resume Next
Dim strComputer
Dim objWMIService
Dim colItems
Dim HWManufacturer
Dim HWModel
Dim CurDirArr
Dim CurDir
Dim Shell
Dim objPNPSignedDrivers
Dim SignedDriver

Set objShell = WScript.CreateObject("Wscript.Shell")
Set objPNPSignedDrivers = GetObject("winmgmts:\\" & ComputerName).InstancesOf("Win32_PnPSignedDriver")

CurDirArr = Split(WScript.ScriptFullName, WScript.ScriptName)
CurDir = CurDirArr(0)

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem In colItems
HWManufacturer = objItem.Manufacturer
HWModel = objItem.Model
wscript.echo HWManufacturer & " " & HWModel
msgbox colItems
Next


wscript.echo HWManufacturer & " " & HWModel

'Remember Uppercase for model number !!!!!


If (InStr(ucase(HWManufacturer), "LENOVO")) Then
WScript.Echo "Installing HW Drivers for " & HWManufacturer

If (Instr(UCase(HWModel), "2508A65")) Then 'x60s
For Each SignedDriver In objPNPSignedDrivers
On Error GoTo 0
If (Instr(UCase(SignedDriver.DeviceClass), "DISPLAY")) and (Instr(UCase(SignedDriver.DriverVersion), "6.14.10.4450")) Then
objShell.Exec "CMD /C " & CurDir & "Install.bat V6.14.10.4450", 1, True
End If
Next
End If

End If

Sub AddReg (tempRegKey,tmpValue,tmpType)
On error resume next
Err.Clear
objShell.RegWrite tempRegKey, tmpValue, tmpType
End Sub

Regards confused new member [:(]

0 Comments   [ + ] Show comments

Answers (9)

Posted by: anonymous_9363 17 years ago
Red Belt
0
- No 'Option Explicit'? Lazy. Undeclared variables will *always* bite you in the end.
- Your first line is 'On Error Resume Next' so any errors are skipped over. How can you ever know if/where anything goes wrong? Lazy. Add proper error-trapping.
- Does the script perform outside of the package?
Posted by: Iglooo 17 years ago
Senior Yellow Belt
0
Hehe, well corrected that one :)
the 2x bat files along with this script is in a separate folder, the install files are in another.
As in there is no custom packaging to the setup catalog along with it's files.

so when distibuted it will be like this
|--- Script folder
folder---
|--- Install files folder

If that is what you were after?
I am limited on info myself, but I am trying.
Posted by: anonymous_9363 17 years ago
Red Belt
0
If that is what you were after?No. This forum is to do with MSI package development. It sounds like this post belongs in the 'Scripting' forum. http://www.appdeploy.com/messageboards/tt.asp?forumid=6 One of the moderators will move it.

Remove the ' On Error Resume Next' and re-run the script. It will then stop at the first error. Take it from there.
Posted by: Iglooo 17 years ago
Senior Yellow Belt
0
Sure, I'll do some more testing and tweaking and come back.
Sorry for the wrong postage.
Posted by: anonymous_9363 17 years ago
Red Belt
0
I ought to have said to comment out the 'On Error Resume Next' because you'll need it when you add your error-trapping.
Posted by: Iglooo 17 years ago
Senior Yellow Belt
0
I have corrected errors, had a third scripter to look at it, and he can't find any flaws as of now.
But the problem I have now, is that it just won't fire up the setup.exe from the script (I tweaked it so I could test it locally)
And the objShell.Exec "CMD /C " & CurDir & "Install.bat V6.14.10.4450", 1, True is switched out with
objShell.Exec "local path\setup.exe", 1, True to check if it will just initiate the install.
But alas it won't. Any tips?

Thanks.
Posted by: Iglooo 17 years ago
Senior Yellow Belt
0
Good news for the moment!
I managed to fire up the setup.exe file, now I just have to finnish up the script and from there try to make it go trough the second .bat file.

*EDIT*
So I understand that
For Each SignedDriver In objPNPSignedDrivers
On Error GoTo 0
If (Instr(UCase(SignedDriver.DeviceClass), "DISPLAY")) and (Instr(UCase(SignedDriver.DriverVersion), "6.14.10.4450"))

Is not working out as I hoped it would..
What I am in need of is that it should check if it is a certain driver version or below > install
or if it is the newest version (at the time of writing this script) or higher > don't install

so, any tips on how to accomplish this?
Thanks in advance. :-)
Posted by: anonymous_9363 17 years ago
Red Belt
0
Have you checked what's being returned in SignedDriver.DriverVersion and its data type? Is it in the format you're testing for? Run the script through the MS Script Debugger (free download from MS) or the MS Script Editor if you have VS and add a 'Stop' statement just before your 'If' construct. Then use the Immediate window to test what's in that property.
Posted by: Iglooo 17 years ago
Senior Yellow Belt
0
"The expression cannot be evaluated while in run mode."
"The expression cannot be evaluated while in design mode."
[:@]

But I managed to tweak it some more, it does not do any compares. But since the computers this script is designed to check it needs the exact same driver version in order for this script to now complete, and i just had a successfull test locally.
But thanks for the help, you kick-started my brain [:D]
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ