Run exe with parameters windows

Silent run installer (.exe) with parameters on Windows

I have a windows setup file (.exe), which is used to install a software. This is a third party executable. During installation, it expects certain values and has a UI. I want to run this setup .exe silently without any manual intervention (even for providing the parameter values). After spending some time googling about the approach, I feel powershell should be able to help me with my requirements. Can anyone suggest if powershell would be the right tool for this, or does a better tool exists to get this requirement? Can python be used to implement this requirement?

Please note: Since this is a third party executable, I don’t have the names of the parameters for which values must be provided to the UI during installation

2 Answers 2

Deployment: Note that it is not always possible to run a setup.exe silently with full control of parameters and with reliable silent running. It depends on how the installer was designed. In these cases I normally resort to repackaging — some more detail below on this.

Some general tips for dealing with deployment:

Software Library Tip: Maybe try to look up the software to see if others have dealt with it for silent installation and deployment: https://www.itninja.com/software

Extract Files: Is this an embedded MSI (Windows Installer) file or a legacy style setup.exe ? Maybe try to extract the files first: Programmatically extract contents of InstallShield setup.exe (Installshield setup.exe files). More elaborate details:

  • How to run an installation in /silent mode with adjusted settings (extraction of non-Installshield setup.exe files — for example Advanced Installer or WiX setup.exe files)
  • Extract MSI from EXE
Читайте также:  Кодек пак для windows media player

Setup.exe: Just adding for completeness. You can try setup.exe /? or setup.exe /help or similar at the command line to check for embedded help in the exe.

MSI Transforms: If you discover and embedded MSI file in the setup.exe, then you can customize the installation parameters in a standardized way. details here: How to make better use of MSI files. Light weight customization is by command line, heavy weight customization via transforms.

Legacy Setup.exe: Legacy setup.exe are often created with Inno Setup, NSIS, or a few other non-MSI setup authoring tools. Each with their own quirks for command line. Here is an old source for some samples: http://unattended.sourceforge.net/installers.php.

Repackaging: Corporate users often repackage such legacy setup.exe files and turn them into MSI or App-V packages (or the brand new MSIX format). On the topic of repackaging and also a piece on PowerShell and the availability of Windows Installer PowerShell Modules: How can I use powershell to run through an installer?.

Some Further Links:

Create a batch file to run an .exe with an additional parameter

I need a batch file which will do the following:

How can I do this?

I tried this but with no luck:

Update

I’ve used the solution provided by Ganesh (below) and came up with this:

I’ve tested it on a local machine (changing the directories) but on the server (with the directory above) it does not work.

The folder directory with batch file:

The error

3 Answers 3

in batch file abc.bat

I am assuming that your executible.exe is present in c:\user\ben_dchost\documents\ I am also assuming that the parameters it takes are -flag1 -flag2 -flag3

Читайте также:  Amd64 microsoft windows что это

For the command you say you want to execute, do:

Hope this helps

Help on commands start and cd is output by executing in a command prompt window help start or start /? and help cd or cd /? .

But I do not understand why you need a batch file at all for starting the application with the additional parameter. Create a shortcut (*.lnk) on your desktop for this application. Then right click on the shortcut, left click on Properties and append after a space character «%USERPROFILE%\Desktop\BGInfo\dc_bginfo.bgi» as parameter.

Found another solution for the same. It will be more helpful.

START C:\»Program Files (x86)»\Test\»Test Automation»\finger.exe ConfigFile=»C:\Users\PCName\Desktop\Automation\Documents\Validation_ZoneWise_Default.finger.Config»

finger.exe is a parent program that is calling config solution. Note: if your path folder name consists of spaces, then do not forget to add «».

Not the answer you’re looking for? Browse other questions tagged batch-file cmd or ask your own question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

How to run an EXE file in PowerShell with parameters with spaces and quotes

How do you run the following command in PowerShell?

C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe -verb:sync -source:dbfullsql=»Data Source=mysource;Integrated Security=false;User -dest:dbfullsql=»Data Source=.\mydestsource;Integrated Security=false;User >

19 Answers 19

When PowerShell sees a command starting with a string it just evaluates the string, that is, it typically echos it to the screen, for example:

Читайте также:  Как посмотреть версию apache linux

If you want PowerShell to interpret the string as a command name then use the call operator (&) like so:

After that you probably only need to quote parameter/argument pairs that contain spaces and/or quotation chars. When you invoke an EXE file like this with complex command line arguments it is usually very helpful to have a tool that will show you how PowerShell sends the arguments to the EXE file. The PowerShell Community Extensions has such a tool. It is called echoargs. You just replace the EXE file with echoargs — leaving all the arguments in place, and it will show you how the EXE file will receive the arguments, for example:

Using echoargs you can experiment until you get it right, for example:

It turns out I was trying too hard before to maintain the double quotes around the connection string. Apparently that isn’t necessary because even cmd.exe will strip those out.

BTW, hats off to the PowerShell team. They were quite helpful in showing me the specific incantation of single & double quotes to get the desired result — if you needed to keep the internal double quotes in place. 🙂 They also realize this is an area of pain, but they are driven by the number of folks are affected by a particular issue. If this is an area of pain for you, then please vote up this PowerShell bug submission.

For more information on how PowerShell parses, check out my Effective PowerShell blog series — specifically item 10 — «Understanding PowerShell Parsing Modes»

UPDATE 4/4/2012: This situation gets much easier to handle in PowerShell V3. See this blog post for details.

Оцените статью