Jump to content

What is wrong with this vbs script


Recommended Posts

I have a vbs that installed Photoshop elements 10.

This cmd file works fine and Photoshop elements 10, the program installs silently perfect.


start/wait Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244"

Then I put the same command above in a vbs script because it adds some success codes for when I am using SCCM and Photoshop elements no longer silently installs. The installations starts and it all becomes manual.


Set sho = Wscript.CreateObject("Wscript.Shell")
strCommand = "Setup.exe /UL1033 /V'SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244'"
intRet = sho.run(strCommand,0,True)
If intRet = 3010 Or intRet = 255 Then
intRet = 0
End If
wscript.quit(intRet)

Edited by clivebuckwheat
Link to comment
Share on other sites


You have only one of the below at the end before the quote mark ,could that becausing the problem

'

COUNTRY=244'"

If you need a area double quoted use Chr(34) = "

Test VBS I used to test the strrCommand


'strCommand = " Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244'"
strCommand = "Setup.exe /UL1033 /V" & Chr(34) & "SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" & Chr(34)
WScript.Echo strcommand

Change From


strCommand = " Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244'"

The above errors out at the /V" because it missing the matching "

Chage To


strCommand = "Setup.exe /UL1033 /V" & Chr(34) & "SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" & Chr(34)

How the Change To would be read at run time

Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244"

Link to comment
Share on other sites

You have only one of the below at the end before the quote mark ,could that becausing the problem

'

COUNTRY=244'"

If you need a area double quoted use Chr(34) = "

Test VBS I used to test the strrCommand


'strCommand = " Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244'"
strCommand = "Setup.exe /UL1033 /V" & Chr(34) & "SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" & Chr(34)
WScript.Echo strcommand

Change From


strCommand = " Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244'"

The above errors out at the /V" because it missing the matching "

Chage To


strCommand = "Setup.exe /UL1033 /V" & Chr(34) & "SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" & Chr(34)

How the Change To would be read at run time

Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244"

thanks

strCommand = "Setup.exe /UL1033 /V" & Chr(34) & "SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" & Chr(34)

Works the install is silent again.

You said I am missing a " in my original vbs script above. Where? I really don't see it :blink:

Here is the original again

Set sho = Wscript.CreateObject("Wscript.Shell")
strCommand = "Setup.exe /UL1033 /V'SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244'"
intRet = sho.run(strCommand,0,True)
If intRet = 3010 Or intRet = 255 Then
intRet = 0
End If
wscript.quit(intRet)

Link to comment
Share on other sites

Then I put the same command above in a vbs script

It seems to me like being NOT the same:

in the batch:

Setup.exe /UL1033 /V doublequote SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244 doublequote

in the VBS:

doublequote Setup.exe /UL1033 /V singlequote SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244 singlequote doublequote

jaclaz

Link to comment
Share on other sites

Then I put the same command above in a vbs script

It seems to me like being NOT the same:

in the batch:

Setup.exe /UL1033 /V doublequote SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244 doublequote

in the VBS:

doublequote Setup.exe /UL1033 /V singlequote SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244 singlequote doublequote

jaclaz

You are wrong

This is how it interpids the line at runtime on the second line of the Example script

Setup.exe /UL1033 /V "SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244"

The quotes are remove when it being process by the script, when it see a double "" it only read one. Chr(34) = " so it knows the serial number

has quotes around it.

strCommand = "Setup.exe /UL1033 /V" & Chr(34) & "SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" & Chr(34) 

When the script process the line it checks to make sure there none of " these are missing

In his original script he was trying to double quote EX "Sting In Quotes" so the script

will read it like Sting In Quotes where as he needs it to be read as "Sting In Quotes"

Clive can you see what wrong here

244'"

244"

Link to comment
Share on other sites

You are wrong

No, I am not, I only read what clivebuckwait posted:

Here is the original again

Set sho = Wscript.CreateObject("Wscript.Shell")
strCommand = "Setup.exe /UL1033 /V'SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244'"

Which actually is:

doublequote Setup.exe /UL1033 /V singlequote SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244 singlequote doublequote

and is ACTUALLY DIFFERENT from what he initially posted as the batch line, which still remains:

Setup.exe /UL1033 /V doublequote SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244 doublequote

I don't know (or care) how VBS parses the posted lines, I only highlighted how the two are NOT the same (nothing more, nothing less).

jaclaz

Link to comment
Share on other sites

Cmd line it not wrapped in quotes

start/wait Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244"

VBS requires quotes around the string or the string would be read like a varible that empty


"Setup.exe /UL1033 /V" & Chr(34) & "SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" & Chr(34)

Interpid this way by Cscript.exe or Wscript.exe

His Code


Setup.exe /UL1033 /V

My Code


Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244"


MsgBox "Line 1 " & Some & Text & vbCrLf & "Line 2 Some Text",4128,"Test"

will produce

---------------------------

Test

---------------------------

Line 1

Line 2 Some Text

---------------------------

OK

---------------------------

His origianl script was failing because he did not have it quoted correct

Link to comment
Share on other sites

I always find it easier to enclose a string with double quotes using the VBS Chr(34) then trying to count how many quotes are needed.

A Way without Chr(34)

strCommand = "Setup.exe /UL1033 /V""SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244"""

Produces

Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244"
Link to comment
Share on other sites

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...