# Remotely execute .exe with parameters

**URL:** <https://forums.powershell.org/t/remotely-execute-exe-with-parameters/10611>\
**Category:** PowerShell Help\
**Created:** [May 1, 2018, 9:05am UTC](https://forums.powershell.org/t/remotely-execute-exe-with-parameters/10611 "2018-05-01T09:05:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![madams](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@madams](https://forums.powershell.org/u/madams)\
**Post date:** [May 1, 2018, 9:05am UTC](https://forums.powershell.org/t/remotely-execute-exe-with-parameters/10611/1 "2018-05-01T09:05:30Z")

</div>

I’m trying to call a .exe file on remote servers and pass parameters. I’ve tried a few methods, start-process and {&‘dir/file.exe’} and can’t seem to get it right.

here’s my code:

```
Invoke-Command -Computername $computer -ScriptBlock {Start-Process -Filepath "C:/Scripts/File.Exe" -ArgumentList 'username', 'password', 'action'}
```

I think it has to do with the differences powershell parses arguments verses cmd.exe, thoughts?

---

<div class="post-metadata">

**Author:** ![ta11ow](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ta11ow/32/131_2.png) [@ta11ow](https://forums.powershell.org/u/ta11ow)\
**Post date:** [May 1, 2018, 11:33am UTC](https://forums.powershell.org/t/remotely-execute-exe-with-parameters/10611/2 "2018-05-01T11:33:16Z")

</div>

Is this file stored locally on your computer or on the server(s) themselves? Only files local to each server could be executed with this method – otherwise you need to provide a UNC path (e.g., “\COMPNAME\C$\Scripts\File.exe”). Either way, if this is a Windows server, you should be using back-slashes for the path not forward-slashes, although in a lot of cases it won’t matter that much.

Is this an interactive program, or will this result in a purely command-line execution? Only the latter can function with Invoke-Command.

Are you passing in the parameters as variables? If these variables come from the wider script, you need to prefix them in your Invoke-Command block with $using: (e.g., $using:VARNAME)

What does calling this application locally look like?

---

<div class="post-metadata">

**Author:** ![madams](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@madams](https://forums.powershell.org/u/madams)\
**Post date:** [May 1, 2018, 11:47am UTC](https://forums.powershell.org/t/remotely-execute-exe-with-parameters/10611/3 "2018-05-01T11:47:45Z")

</div>

Thanks for the reply:

1. Remote computer not on local machine of the powershell script

2. Execution of the program works in cmd.exe when i call (after cd to correct directory) ./file.exe username password action

---

<div class="post-metadata">

**Author:** ![ta11ow](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ta11ow/32/131_2.png) [@ta11ow](https://forums.powershell.org/u/ta11ow)\
**Post date:** [May 1, 2018, 1:36pm UTC](https://forums.powershell.org/t/remotely-execute-exe-with-parameters/10611/4 "2018-05-01T13:36:23Z")

</div>

Can you give an example of syntax? Are there spaces in any of the arguments you need to pass? Do they involve switches, or is it literally just ‘filename.exe USER PASS ACTION’?

Try adding the -Wait parameter to the Start-Process call, as well. Perhaps the remote non-interactive session is playing a bit funky with how the application is accustomed to behaving.

---

<div class="post-metadata">

**Author:** ![madams](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@madams](https://forums.powershell.org/u/madams)\
**Post date:** [May 1, 2018, 1:52pm UTC](https://forums.powershell.org/t/remotely-execute-exe-with-parameters/10611/5 "2018-05-01T13:52:38Z")

</div>

Open command prompt:

cd /dir of exe file

./file.exe user pass action

application begins to run accepting the 3 parameters from the command line into string args

---

<div class="post-metadata">

**Author:** ![ta11ow](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ta11ow/32/131_2.png) [@ta11ow](https://forums.powershell.org/u/ta11ow)\
**Post date:** [May 1, 2018, 2:52pm UTC](https://forums.powershell.org/t/remotely-execute-exe-with-parameters/10611/6 "2018-05-01T14:52:33Z")

</div>

The only thing I can think of is some kind of permissions issue, I suppose. Most applications should run fine through Invoke-Command unless they don’t have a CLI.

---

<div class="post-metadata">

**Author:** ![velagabalaji](https://avatars.discourse-cdn.com/v4/letter/v/ebca7d/32.png) [@velagabalaji](https://forums.powershell.org/u/velagabalaji)\
**Post date:** [May 2, 2018, 8:00am UTC](https://forums.powershell.org/t/remotely-execute-exe-with-parameters/10611/7 "2018-05-02T08:00:21Z")

</div>

I want to enable the remote session(PS remoting) via Registry, can anyone help.

---

<div class="post-metadata">

**Author:** ![ta11ow](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ta11ow/32/131_2.png) [@ta11ow](https://forums.powershell.org/u/ta11ow)\
**Post date:** [May 2, 2018, 9:41am UTC](https://forums.powershell.org/t/remotely-execute-exe-with-parameters/10611/8 "2018-05-02T09:41:20Z")

</div>

1. As it also requires a service to be running, it probably cannot be done _entirely_ with registry settings
2. Please create a new thread, this is unrelated to the original question. 🙂

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:35pm UTC](https://forums.powershell.org/t/remotely-execute-exe-with-parameters/10611/9 "2024-05-16T20:35:06Z")

</div>


