![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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...??? 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 Specs![]() |
| | #4 (permalink) |
| | 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 , 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
| | #6 (permalink) |
| | 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'. 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. 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 Specs![]() |
![]() |
| 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 | |||