Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Run command problem in vbs

Reply
 
Old 02-07-2009   #1 (permalink)
Tcs


 
 

Run command problem in vbs

I only want the setup.exe to run if the version of the LDISCN32.EXE
file <> "8.70.8.22". On the machine on which I have been testing
this, I KNOW the version IS "8.70.8.22". So...it should NOT run. But
EVERY time I try to run this...it executes the setup.exe.

What am I doing wrong? Am I not checking the version correctly?
Or...???

Thanks in advance,

Tom

-----

' Checks the version of ldiscn32.exe and cranks up sp6 install if the
rev is <> sp6

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_Datafile Where name = 'C:\\Program
Files\\LANDesk\\LDClient\\LDISCN32.EXE'")

For Each objFile in colFiles
If objFile.Version <> "8.70.8.22" Then

WScript.Echo _
"Made it to the execution partion..."

strCmd = "%comspec% /c csccmd
\\LDSVR001\LANDesk\LD87-SP6-Client\setup.exe -S"

Set objShell = CreateObject("Wscript.Shell")
intReturn = objShell.Run(strCmd, 2, True)
Wscript.Echo "Return code: " & CStr(intReturn)

End If
Next

My System SpecsSystem Spec
Old 02-08-2009   #2 (permalink)
urkec


 
 

RE: Run command problem in vbs

"Tcs" wrote:
Quote:

> I only want the setup.exe to run if the version of the LDISCN32.EXE
> file <> "8.70.8.22". On the machine on which I have been testing
> this, I KNOW the version IS "8.70.8.22". So...it should NOT run. But
> EVERY time I try to run this...it executes the setup.exe.
>
> What am I doing wrong? Am I not checking the version correctly?
> Or...???
>
> Thanks in advance,
>
> Tom
>
> -----
>
> ' Checks the version of ldiscn32.exe and cranks up sp6 install if the
> rev is <> sp6
>
> strComputer = "."
>
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer &
> "\root\cimv2")
> Set colFiles = objWMIService.ExecQuery _
> ("Select * from CIM_Datafile Where name = 'C:\\Program
> Files\\LANDesk\\LDClient\\LDISCN32.EXE'")
>
> For Each objFile in colFiles
> If objFile.Version <> "8.70.8.22" Then
>
> WScript.Echo _
> "Made it to the execution partion..."
>
> strCmd = "%comspec% /c csccmd
> \\LDSVR001\LANDesk\LD87-SP6-Client\setup.exe -S"
>
> Set objShell = CreateObject("Wscript.Shell")
> intReturn = objShell.Run(strCmd, 2, True)
> Wscript.Echo "Return code: " & CStr(intReturn)
>
> End If
> Next
>


It is possible that objFile.Version doesn't contain what you expect. Try to
check it before the comparison:


strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_Datafile " & _
"Where name = 'C:\\Program Files\\LANDesk\\LDClient\\LDISCN32.EXE'")

For Each objFile in colFiles

WScript.Echo objFile.Version

If objFile.Version <> "8.70.8.22" Then
WScript.Echo "Made it to the execution partion..."
End If

Next



--
urkec



My System SpecsSystem Spec
Old 02-08-2009   #3 (permalink)
Al Dunbar


 
 

Re: Run command problem in vbs


"Tcs" <someone@xxxxxx> wrote in message
news:3ncso49q9v7h2e4j9ashuqgv6ikpp38pbt@xxxxxx
Quote:

>I only want the setup.exe to run if the version of the LDISCN32.EXE
> file <> "8.70.8.22". On the machine on which I have been testing
> this, I KNOW the version IS "8.70.8.22". So...it should NOT run. But
> EVERY time I try to run this...it executes the setup.exe.
>
> What am I doing wrong? Am I not checking the version correctly?
> Or...???
I do not know for sure, but it could be that there is some difference in
data types that is causing this problem. I'd suggest that you see what the
typename and vartype functions have to say about objFile.Version and
"8.70.8.22", to see if they are the same. If not, then I'd convert one or
both to the same type. It might just be, for example, that .Version returns
an array.

/Al
Quote:

> Thanks in advance,
>
> Tom
>
> -----
>
> ' Checks the version of ldiscn32.exe and cranks up sp6 install if the
> rev is <> sp6
>
> strComputer = "."
>
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer &
> "\root\cimv2")
> Set colFiles = objWMIService.ExecQuery _
> ("Select * from CIM_Datafile Where name = 'C:\\Program
> Files\\LANDesk\\LDClient\\LDISCN32.EXE'")
>
> For Each objFile in colFiles
> If objFile.Version <> "8.70.8.22" Then
>
> WScript.Echo _
> "Made it to the execution partion..."
>
> strCmd = "%comspec% /c csccmd
> \\LDSVR001\LANDesk\LD87-SP6-Client\setup.exe -S"
>
> Set objShell = CreateObject("Wscript.Shell")
> intReturn = objShell.Run(strCmd, 2, True)
> Wscript.Echo "Return code: " & CStr(intReturn)
>
> End If
> Next

My System SpecsSystem Spec
Old 02-08-2009   #4 (permalink)
ekkehard.horner


 
 

Re: Run command problem in vbs

Tcs schrieb:
Quote:

> I only want the setup.exe to run if the version of the LDISCN32.EXE
> file <> "8.70.8.22". On the machine on which I have been testing
> this, I KNOW the version IS "8.70.8.22". So...it should NOT run. But
> EVERY time I try to run this...it executes the setup.exe.
[...]
To merge urkec's and Al Dunbar's advice:
Quote:

> For Each objFile in colFiles
WScript.Echo objFile.Name _
, objFile.Version _
, ">" & objFile.Version & "<" _
, TypeName( objFile.Version )
Quote:

> If objFile.Version <> "8.70.8.22" Then
[...]

For me, TypeName( objFile.Version ) returns: "String"
My System SpecsSystem Spec
Old 02-08-2009   #5 (permalink)
Tcs


 
 

Re: Run command problem in vbs

Thanks guys.

I thought that I had checked...sufficiently. Obviously, I was wrong.
Seems that the string contains two spaces on the end, following the
'22'.

Script works properly now. I appreciate the help.

Tom

On Sun, 08 Feb 2009 20:23:05 +0100, "ekkehard.horner"
<ekkehard.horner@xxxxxx> wrote:
Quote:

>Tcs schrieb:
Quote:

>> I only want the setup.exe to run if the version of the LDISCN32.EXE
>> file <> "8.70.8.22". On the machine on which I have been testing
>> this, I KNOW the version IS "8.70.8.22". So...it should NOT run. But
>> EVERY time I try to run this...it executes the setup.exe.
>[...]
>To merge urkec's and Al Dunbar's advice:
Quote:

>> For Each objFile in colFiles
>
> WScript.Echo objFile.Name _
> , objFile.Version _
> , ">" & objFile.Version & "<" _
> , TypeName( objFile.Version )
>
Quote:

>> If objFile.Version <> "8.70.8.22" Then
>[...]
>
>For me, TypeName( objFile.Version ) returns: "String"
My System SpecsSystem Spec
Old 02-08-2009   #6 (permalink)
Al Dunbar


 
 

Re: Run command problem in vbs


"Tcs" <someone@xxxxxx> wrote in message
news:4qnuo4150628n1qeqb80t8ohbar70kubgl@xxxxxx
Quote:

> Thanks guys.

You're welcome,
Quote:

> I thought that I had checked...sufficiently. Obviously, I was wrong.
> Seems that the string contains two spaces on the end, following the
> '22'.
Ah, the old "invisible" trailing whitespace - kills you every time. It is
always a problem that you will not see this when you display a string
variable - unless you bracket it somehow, as in "[" & variable & "]". The
"=" and "<>" comparison operators do not include an implicit "close enough
is close enough", and generally look for an exact match.
Quote:

> Script works properly now. I appreciate the help.
Like most scripts, it always worked - it was just doing something you did
not intend! ;-)

/Al
Quote:

> Tom
>
> On Sun, 08 Feb 2009 20:23:05 +0100, "ekkehard.horner"
> <ekkehard.horner@xxxxxx> wrote:
>
Quote:

>>Tcs schrieb:
Quote:

>>> I only want the setup.exe to run if the version of the LDISCN32.EXE
>>> file <> "8.70.8.22". On the machine on which I have been testing
>>> this, I KNOW the version IS "8.70.8.22". So...it should NOT run. But
>>> EVERY time I try to run this...it executes the setup.exe.
>>[...]
>>To merge urkec's and Al Dunbar's advice:
Quote:

>>> For Each objFile in colFiles
>>
>> WScript.Echo objFile.Name _
>> , objFile.Version _
>> , ">" & objFile.Version & "<" _
>> , TypeName( objFile.Version )
>>
Quote:

>>> If objFile.Version <> "8.70.8.22" Then
>>[...]
>>
>>For me, TypeName( objFile.Version ) returns: "String"

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Re: Problem with Command Interpreter Vista General
Re: Problem with Command Interpreter Vista General
Re: Problem with Command Interpreter Vista General
Problem with get-command PowerShell
Command completion problem. PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46