Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

What is wrong with this vbs script

- - - - -

  • Please log in to reply
8 replies to this topic

#1
clivebuckwheat

clivebuckwheat

    Senior Member

  • Member
  • PipPipPipPip
  • 569 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, 30 September 2012 - 10:28 AM.



How to remove advertisement from MSFN

#2
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,418 posts
  • OS:none specified
  • Country: Country Flag
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"




GunSmokingMan



#3
clivebuckwheat

clivebuckwheat

    Senior Member

  • Member
  • PipPipPipPip
  • 569 posts

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)


#4
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,266 posts
  • OS:none specified
  • Country: Country Flag

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

#5
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,418 posts
  • OS:none specified
  • Country: Country Flag


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"



GunSmokingMan



#6
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,266 posts
  • OS:none specified
  • Country: Country Flag

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

#7
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,418 posts
  • OS:none specified
  • Country: Country Flag
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


GunSmokingMan



#8
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,266 posts
  • OS:none specified
  • Country: Country Flag

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

I know :), that's why I highlighted the conceptual error of stating that the two command lines were the same.

jaclaz

#9
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,418 posts
  • OS:none specified
  • Country: Country Flag
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"




GunSmokingMan






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN