run a remote EXE with argument, from a user share but have the command run on the server that the share resides on, not local machine.

Carl Jeffreys 1 Reputation point
2020-08-03T12:23:22.54+00:00

I have an executable that requires an argument to follow it, namely a root directory.

I have the executable installed with i's dependancies on a server.

A user will add content to the root directory, and then need to execute the exe. However, to supply the argument to the executable I need to call it in a command line.

How do I go about creating a link for users who access a remote share, so that a user may click on an object, and launch the application on the share along with it's argument, and have it so that all teh work takes place on teh remote server, non on the local machien of the user trying to launch the app.

I;ve tried a few things in powershell and CMD, but can't get the app to function remotely, with the additional required string dictating the root area...

Any help very welcomed

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,431 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Rich Matheisen 45,416 Reputation points
    2020-08-05T19:59:05.167+00:00

    How about this?

    $Directory = "d:\rootfilepath"
    
    # this is not really the preferred way
    Invoke-Command -Computer SERVERNAME -ScriptBlock {& "D:\incomingdatafiles\datafileloader\datafileloader\callDatafileUploader1.ps1 $using:Directory"}
    
    # This is safer (and preferred)
    Invoke-Command -Computer SERVERNAME -ScriptBlock {Start-Process -NoNewWindow -FilePath "D:\incomingdatafiles\datafileloader\datafileloader\callDatafileUploader1.ps1" -ArgumentList $using:Directory}
    
    1 person found this answer helpful.

  2. Rich Matheisen 45,416 Reputation points
    2020-08-03T14:50:06.2+00:00

    What are the things you've tried???? Was Invoke-Command one of them? The PowerShell script will run on the local machine, but the application will run on the remote server. They'll still have to wait for the command to complete, but it won't be running on the local machine.


  3. 2020-08-05T01:43:19.557+00:00

    If you want to get help on the script, please show the command or script you are trying so that members and experts of our forum can help you. (Remember to delete the personal privacy section)


  4. Dave Patrick 426.3K Reputation points MVP
    2020-08-05T20:01:19.543+00:00

    You can use PSExec for this.
    https://learn.microsoft.com/en-us/sysinternals/downloads/psexec

    --please don't forget to Accept as answer if the reply is helpful--


  5. 2020-08-20T01:42:38.42+00:00

    Hi, given that this post has been quiet for a while, this is a quick question and answer. Has your question been solved? If so, please mark it as an answer so that users with the same question can find and get help.
    ( Does the latest problem idea from RichMatheisen-8856 help you? )

    0 comments No comments