Reputation: 1
I can silently uninstall application which doesn't have password Protected using Powershell .
Start-Process -Wait -FilePath $uninstall32 /SILENT
For password protected application (Setup created using Inno SetUp ) it popup for asking password. Is there an option to pass password without popup?
If it succeeds I want to remotely uninstall password protected application
Without password protected application remotely I had uninstalled silently.
I tried
Start-Process -Wait -FilePath $uninstall32 UNINSTALL_PASSWORD =AR /SILENT
Upvotes: 0
Views: 416
Reputation: 439822
tl;dr
Specify the pass-through arguments as a single string:
# Note: Parameters -FilePath and -ArgumentList are positionally implied.
Start-Process -Wait $uninstall32 'UNINSTALL_PASSWORD=AR /SILENT'
If you need to embed variable references or expressions in the arguments string, use "..."
quoting, i.e. an expandable (double-quoted) string , rather than '...'
, a verbatim (single-quoted) string .
When you use Start-Process
, any arguments to be passed to the target executable (-FilePath
) must be specified via the -ArgumentList
(-Args
) parameter, to which you must pass a single value.
-ArgumentList
technically accepts an array of string values,[1] allowing you to specify the pass-through arguments individually, separated with ,
a long-standing bug unfortunately makes it better to encode all arguments in a single string, because it makes the situational need for embedded double-quoting explicit - see this answer.Both parameters can be bound positionally, meaning that values need not be prefixed with the target parameter names.
Therefore, your attempt:
# !! BROKEN
Start-Process -Wait -FilePath $uninstall32 UNINSTALL_PASSWORD =AR /SILENT
is equivalent to:
# !! BROKEN
Start-Process -Wait -FilePath $uninstall32 -ArgumentList UNINSTALL_PASSWORD =AR /SILENT
and also equivalent to, using positional parameter binding for both -FilePath
and -ArgumentList
:
# !! BROKEN
Start-Process -Wait $uninstall32 UNINSTALL_PASSWORD =AR /SILENT
That is, UNINSTALL_PASSWORD
alone was bound to -ArgumentList
, whereas =AR
and /SILENT
are additional, positional arguments that cause a syntax error, because both parameters that support positional binding - -FilePath
and -ArgumentList
- are already bound.
[1] From PowerShell's perspective, even an array of values (,
-separated values) is a single argument.
Upvotes: 0