Incroyable HULK Posted March 27, 2006 Share Posted March 27, 2006 (edited) Hello All,I'm trying to install Symantec Antivirus 10 & Windows Media Player 10 but I can't seem to figure out the proper syntax for the VBScript function:WshShell.Run("\"D:\Symantec AntiVirus.msi\" /qb-!", 1, True)WshShell.Run("D:\WMP10.exe /Q:A /C:\"setup_wm.exe /Q /R:N /DisallowSystemRestore\"", 1, True)The problem is coming from the use of surrounding \"BTW, I know all I have to do for Symantec is to rename the .msi file without space and remove the surrounding \" but this won't work for Media Player... Edited March 27, 2006 by Incroyable HULK Link to comment Share on other sites More sharing options...
RogueSpear Posted March 27, 2006 Share Posted March 27, 2006 (edited) Here is a script that should illustrate two things for you. First is the proper way to install .msi based software from within a VBscript. Second, there is a demonstration of constructing and executing a fairly complex 7-Zip command line from within a VBscript.There are times when you need to get a little creative as well. Here is an example where you actually need to use four quotes on either side of a variable:If fs.FileExists(OEM & "\101_AllUsers.7z") Then ws.Run(str7Zcmd & "\101_AllUsers.7z -o" & """" & allusers & """"),0,Truethe variable allusers is mapped to the environment variable %AllUsersProfile% elsewhere in the script. The thing to keep in mind is that with native WSH commands you often don't need to worry about long file names with spaces in them, but with ws.Run whatever is in there is being passed along to the command interpreter. So you do need to care. Keeping in mind the rule of using double quotes to simulate a quote, I figured (correctly) that using four quotes would simulate a double quote Whenever you need to simulate a double quote however you need to seperate it off from the rest by use of the &.EDIT: Got a little carried away there and forgot to mention that your options need to be outside of the parenthesis. Notice in the code above """"), 0, True. The options are after the closing parenthesis.130_Streets.7z Edited March 27, 2006 by RogueSpear Link to comment Share on other sites More sharing options...
gunsmokingman Posted March 27, 2006 Share Posted March 27, 2006 You do not need extra backslashes in the path("\"D:\Symantec AntiVirus.msi\" /qb-!", 1, True)"D:\WMP10.exe /Q:A /C:\"setup_wm.exe /Q /R:N /DisallowSystemRestore\"",I have included 2 examples I works the other does not workThis does not worked Dim Act : Set Act = CreateObject("Wscript.shell") Act.Run("D:\Net Radio Test.exe")1, TrueThis worked Dim Act : Set Act = CreateObject("Wscript.shell") Act.Run(chr(34) & "D:\Net Radio Test.exe" & chr(34)), 1, TrueI have edited the Symantec so it correct. You may have to add chr(34) to this WMP code, but the rest is correct for it.Dim Act : Set Act = CreateObject("Wscript.shell") Act.Run(chr(34) & "D:\Symantec AntiVirus.msi\ /qb-!" & chr(34)), 1, True Act.Run("D:\WMP10.exe /Q:A /C:\setup_wm.exe /Q /R:N /DisallowSystemRestore"), 1, True Link to comment Share on other sites More sharing options...
Incroyable HULK Posted March 27, 2006 Author Share Posted March 27, 2006 (edited) @ GunSmokingManSorry GSM but it doesn't work...I tried several combinations and most of the time I get a warning about "File not Found" for SAV10 or "Syntax error in command line" for WMP10The extra backslashes (\") in the command line are there to escape the quote caracter... I don't understand why you kept them in your example:You do not need extra backslashes in the pathI have edited the Symantec so it correct. You may have to add chr(34) to this WMP code, but the rest is correct for it.Dim Act : Set Act = CreateObject("Wscript.shell") Act.Run(chr(34) & "D:\Symantec AntiVirus.msi\ /qb-!" & chr(34)), 1, True Act.Run("D:\WMP10.exe /Q:A /C:\setup_wm.exe /Q /R:N /DisallowSystemRestore"), 1, True@ RogueSpearOMG! I don't even know where to start to modify my syntax!Regarding the parenthesis, I think there is several way to do this:WshShell.Run("D:\SymantecAntiVirus.msi /qb-!", 1, True)orWshShell.Run("D:\SymantecAntiVirus.msi /qb-!"), 1, TrueorWshShell.Run "D:\SymantecAntiVirus.msi /qb-!", 1, TrueAll of them works! Edited March 27, 2006 by Incroyable HULK Link to comment Share on other sites More sharing options...
Yzöwl Posted March 27, 2006 Share Posted March 27, 2006 Why not just replace the backslash escape characters with double quotesWshShell.Run("D:\WMP10.exe /q:A /c:""setup_wm.exe /Q /R:N /DisallowSystemRestore""", 1, True) Link to comment Share on other sites More sharing options...
Incroyable HULK Posted March 27, 2006 Author Share Posted March 27, 2006 NO WAY!!!It works! I guess I overlooked the syntax too many times!!! Thanks guys! Link to comment Share on other sites More sharing options...
Yzöwl Posted March 27, 2006 Share Posted March 27, 2006 It's amazing how often doubling up is overlooked in place of Chr(34).I usually find it easier to test by replacing WshShell.Run with WScript.Echo and look at the screen output.Anyway glad to have helped Link to comment Share on other sites More sharing options...
kasandoro Posted March 27, 2006 Share Posted March 27, 2006 you could have also used &chr(34) to create quotes...works for me every time. Link to comment Share on other sites More sharing options...
gunsmokingman Posted March 27, 2006 Share Posted March 27, 2006 I will have to remeber using double quotes if the chr(34) does not work. You may want to try a script like this this to install, I tested this on Vista to install Winamp, it worked.Dim Act, Fso, WinampSet Act = CreateObject("Wscript.Shell")Set Fso = CreateObject("Scripting.FileSystemObject")Winamp = Act.ExpandEnvironmentStrings("%Systemdrive%\Winamp5.msi")If Fso.FileExists(Winamp) Then Act.Run(winamp & " Xname=Spad Xkey=XXXXX-XXXXX-XXXXX-XXXXX Xagent=0 Xlibrary=0 Xintex=1 Xmodernskin=1 Xaudio=1 Xvideo=0 Xvisual=1 Xextra=1 Xregopt=0 /qr"),1,True Fso.DeleteFile(Winamp)End IfAnother way using a ArrayDim Act, CT, Fso, Install Set Act = CreateObject("Wscript.Shell") Set Fso = CreateObject("Scripting.FileSystemObject") Install = Array(Act.ExpandEnvironmentStrings("%Systemdrive%\SomeApp1.msi"),_ Act.ExpandEnvironmentStrings("%Systemdrive%\SomeApp2.exe"),_ Act.ExpandEnvironmentStrings("%Systemdrive%\SomeApp3.msi"),_ Act.ExpandEnvironmentStrings("%Systemdrive%\SomeApp4.exe"),_ Act.ExpandEnvironmentStrings("%Systemdrive%\Some App 5.exe")) CT = 0 For Each strApp In Install CT = CT + 1 If Fso.FileExists(strApp) Then If CT = 1 Then Act.Run(strApp & " Xname=Spad Xkey=XXXXX-XXXXX-XXXXX-XXXXX Xagent=0 Xlibrary=0 Xintex=1 Xmodernskin=1 Xaudio=1 Xvideo=0 Xvisual=1 Xextra=1 Xregopt=0 /qr"),1,True Fso.DeleteFile(strApp) End If If CT = 2 Then : Act.Run(strApp & " /silent"),1,True : Fso.DeleteFile(strApp) : End If If CT = 3 Then : Act.Run(strApp & " /quiet /noreboot"),1,True : Fso.DeleteFile(strApp) : End If If CT = 4 Then : Act.Run(strApp & " /s /q"),1,True : Fso.DeleteFile(strApp) : End If If CT = 5 Then : Act.Run(Chr(34) & strApp & " /s /q" & Chr(34)),1,True : Fso.DeleteFile(strApp) : End If End If Next Link to comment Share on other sites More sharing options...
RogueSpear Posted March 27, 2006 Share Posted March 27, 2006 Just so you guys know, WMI is a bit faster and uses less resources when installing something from an .msi installer. I always try to minimize the amount of times the command interpreter is invoked. It generally makes for faster running less resource hogging scripts. Link to comment Share on other sites More sharing options...
Incroyable HULK Posted March 27, 2006 Author Share Posted March 27, 2006 Just so you guys know, WMI is a bit faster and uses less resources when installing something from an .msi installer. I always try to minimize the amount of times the command interpreter is invoked. It generally makes for faster running less resource hogging scripts.You mean using the Win32_Products class? Link to comment Share on other sites More sharing options...
RogueSpear Posted March 27, 2006 Share Posted March 27, 2006 Yes. Link to comment Share on other sites More sharing options...
Incroyable HULK Posted March 27, 2006 Author Share Posted March 27, 2006 (edited) I am not sure but I think this class has been removed (or perhaps replaced?) on Windows XP 64-Bits edition (and maybe on Vista 64-Bit edition?) so I wouldn't "build" too much on this class... Edited March 27, 2006 by Incroyable HULK Link to comment Share on other sites More sharing options...
RogueSpear Posted March 27, 2006 Share Posted March 27, 2006 There's certainly something going on. If you take a look at the Symantec AntiVirus Corp V10 distribution, any of the 32-bit application installs (SAV, SSC, etc.) contain the two Windows Installer runtime files, but the SAV x64 client does not. Yet the 64-bit install is an .msi installer. I don't know if this is because XP x64 comes with a more up to date version of Windows Installer where as the 32-bit applications are supposed to be compatible all the way down to NT4.I have a feeling all of this 64-bit stuff is going to require a lot of relearning and workarounds. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now