MSFN Forum: What is wrong with this vbs script - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

What is wrong with this vbs script Rate Topic: -----

#1 User is offline   clivebuckwheat 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 562
  • Joined: 07-November 05

Posted 30 September 2012 - 09:59 AM

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)


This post has been edited by clivebuckwheat: 30 September 2012 - 10:28 AM



#2 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,356
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 30 September 2012 - 10:40 AM

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

Quote


'
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



Quote

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 "


Quote

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"



#3 User is offline   clivebuckwheat 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 562
  • Joined: 07-November 05

Posted 30 September 2012 - 11:22 AM

View Postgunsmokingman, on 30 September 2012 - 10:40 AM, said:

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

Quote


'
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



Quote

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 "


Quote

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 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,572
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 30 September 2012 - 11:32 AM

View Postclivebuckwheat, on 30 September 2012 - 09:59 AM, said:

Then I put the same command above in a vbs script


It seems to me like being NOT the same:
in the batch:

Quote

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

in the VBS:

Quote

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


jaclaz

#5 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,356
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 30 September 2012 - 11:57 AM

View Postjaclaz, on 30 September 2012 - 11:32 AM, said:

View Postclivebuckwheat, on 30 September 2012 - 09:59 AM, said:

Then I put the same command above in a vbs script


It seems to me like being NOT the same:
in the batch:

Quote

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

in the VBS:

Quote

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"



#6 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,572
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 30 September 2012 - 01:07 PM

View Postgunsmokingman, on 30 September 2012 - 11:57 AM, said:

You are wrong

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

View Postclivebuckwheat, on 30 September 2012 - 11:22 AM, said:

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:

Quote

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:

Quote

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 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,356
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 30 September 2012 - 01:43 PM

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

Quote

---------------------------
Test
---------------------------
Line 1

Line 2 Some Text
---------------------------
OK
---------------------------


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

#8 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,572
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 01 October 2012 - 01:33 AM

View Postgunsmokingman, on 30 September 2012 - 01:43 PM, said:

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 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,356
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 01 October 2012 - 12:57 PM

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

Quote

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


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy