0

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
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
  • You tried with `UNINSTALL_PASSWORD =AR` in the argument list, and then what? What happens? Does it exit with an error? Does it ignore the argument and prompt you for the password? – Mathias R. Jessen Jul 18 '23 at 12:35
  • Thank you Mathias for the suggestion . When i tried with this start-process -Wait -FilePath $uninstall32 -ArgumentList UNINSTALL_PASSWORD=AR it pop for Password. A positional parameter cannot be found that accepts argument '/SILENT'. message coming if i add /SILENT after -ArgumentList UNINSTALL_PASSWORD=AR – antony paracka paracka Jul 19 '23 at 04:20

1 Answers1

0

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.

  • Note: While -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.

mklement0
  • 382,024
  • 64
  • 607
  • 775