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.
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 theRunAs
command, however. These steps may help:Determine the proper command line syntax. Test this directly at the command prompt to ensure it's correct.
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.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:Assign it to a VBScript variable. We just need to put additional quotes around the entire command:
Now you're ready to go. You can run this directly with
Shell.Run
:Note that you will still need to use
SendKeys
whenRunAs
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. WithSCHTASKS
, you can pass the complete credentials on the command line.From the comments it is determined the correct install string. For VBS, you can run it (on the machine):
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.