1

I'm trying to launch a program in silent mode, to install a certain application. The command line for launching the installation in silent mode is as follows:

setup.exe /s /v" /q"

I tried using the following: strCmd="C:\setup.exe"" /s /v"""" /q"""

But obviously this doesn't work. Can anyone help me on writing the right syntax. I know there's something wrong with the quotes as an escape character. I have wasted a lot of time trying to figure that out. Any help is highly appreciated.

Pk boss
  • 274
  • 1
  • 13
  • Are you sure this setup.exe can take arguments like that? Should it be `setup.exe /s /v /q`? – PatricK Sep 12 '14 at 05:34
  • Yes, that's the exact syntax for launching the program in silent mode (taken from the program documentation). Also tried it using a command prompt. – John MacMillan Sep 12 '14 at 05:35
  • Tried `strCmd="C:\setup.exe /s /v"" /q"""`? – PatricK Sep 12 '14 at 05:40
  • Just tried your suggestions. No luck :-(. Thanks. – John MacMillan Sep 12 '14 at 05:45
  • The program I'm trying to launch is this: http://www-10.lotus.com/ldd/lcwiki.nsf/dx/Installing_the_IBM_Connections_Plug-ins_for_IBM_Notes Under the part "Silently installing the IBM Connections Plug-ins (Windows) ", you can see the right command to launch for silently installing it – John MacMillan Sep 12 '14 at 05:46
  • Can't get the exe file to test without sign up. Does it give you usage if you `setup.exe /?` I really think they have typo there. Try **`setup.exe /s /v /qn`** – PatricK Sep 12 '14 at 06:07
  • Tried the command setup.exe /s /v /qn.It launches the program normally and not in silent mode. – John MacMillan Sep 12 '14 at 06:13
  • Checked their uninstall doc which is `setup.exe -s -x -v"/qn"`, so I guess you should remove the space in front of **/qn**: `setup.exe /s /v"/qn"` or `strCmd="C:\setup.exe /s /v""/qn"""` – PatricK Sep 12 '14 at 06:23
  • Ok, there are some improvements here. I tried the command setup.exe /s /v"/qn" from a command prompt and it does install silently. So you're right the space is not needed. But now the command strCmd="C:\setup.exe /s /v""/qn""" in the vbscript doesn't work, but this works: strCmd="C:\setup.exe"" /s /v""/qn""", but it does not install. And I tried to pause the screen, and the script said attempting to start setup.exe /s /v/qn, as if the quotes did not exist. Any ideas? Thanks Patrick, much appreciated. – John MacMillan Sep 12 '14 at 07:03
  • I can upload the software somewhere for you so you can try it. It's about 40MB. – John MacMillan Sep 12 '14 at 07:05
  • File uploaded here http://www.filedropper.com/addon – John MacMillan Sep 12 '14 at 07:11

2 Answers2

1

From the comments it is determined the correct install string. For VBS, you can run it (on the machine):

Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "cmd /C C:\setup.exe /s /v""/qn"""
Set oShell = Nothing

If you don't want to use GPO to deploy, you can also push the install task to computers manually with PSEXEC.EXE, it does not require the setup.exe to be on the computer and a network share folder is good for this.

PatricK
  • 6,375
  • 1
  • 21
  • 25
  • Perfect !! That script worked like a charm !! Thanks a million. You are right, I'm planning to use a logon script through GPO to install the software. My only concern is that the users do not have admin rights, so the installation will fail. Therefore I previously had this: Set WshShell=WScript.CreateObject("WScript.Shell") strCmd="C:\setup.exe"" /s /v""/qn""" strUser="domain\admin" strPass="password" set WshShell=CreateObject("WScript.Shell") WshShell.Run "runas.exe" & " /u:" & strUser & " " & strCmd WScript.Sleep 100 WshShell.Sendkeys strPass & "~" – John MacMillan Sep 12 '14 at 08:48
  • But that didn't work. Is it possible to run your script with a domain admin account and pass the password as I have above. The WScript.Sleep 100 is just so that users don't get a black screen on logon while the software is installing. So I'm minimizing that time. And the rest is so that the password is not visible. Many thanks for your help. Been struggling for 3 days on this. – John MacMillan Sep 12 '14 at 08:49
1

If you want to run the command using different credentials, you can use the RunAs command. Things can get tricky when embedding your command within the RunAs command, however. These steps may help:

  1. Determine the proper command line syntax. Test this directly at the command prompt to ensure it's correct.

    c:\setup.exe /s /v"/qn"
    
  2. Embed your command within the RunAs command. Your entire command needs to be surrounded with quotes. In addition, any quotes within your command need to be escaped with \. Again, test this directly at the command prompt to ensure it's correct.

    runas.exe /user:DOMAIN\USER "c:\setup.exe /s /v\"/qn\""
    
  3. Convert the entire command string to VBScript. Wherever you see a quote, double it, or replace it with Chr(34). Here is how it would look when the quotes are doubled:

    runas.exe /user:DOMAIN\USER ""c:\setup.exe /s /v\""/qn\""""
    
  4. Assign it to a VBScript variable. We just need to put additional quotes around the entire command:

    strCommand = "runas.exe /user:DOMAIN\USER ""c:\setup.exe /s /v\""/qn\"""""
    
  5. Now you're ready to go. You can run this directly with Shell.Run:

    With CreateObject("WScript.Shell")
        .Run strCommand
    End With
    

Note that you will still need to use SendKeys when RunAs prompts you for the password, as it provides no way to pass it on the command line.

An alternative method is to use SCHTASKS to schedule a one-time task to be run immediately. With SCHTASKS, you can pass the complete credentials on the command line.

Bond
  • 16,071
  • 6
  • 30
  • 53
  • Absolutely brilliant !! That was flawless !! Bond, Thanks a million for the solution. You are a savior! Also my thanks goes for Patrick for his time. – John MacMillan Sep 13 '14 at 09:40