Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6037209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:02:24+00:00 2026-05-23T06:02:24+00:00

I have read that Win32 will not allow remote invocation of a process that

  • 0

I have read that Win32 will not allow remote invocation of a process that is interactive and I suspect a Console Application is considered to be interactive by Windows and so instead, if I could convert the following code in to a batch file then I am hoping I can remotely run the batch file on the server computer from a client. Feel free to correct this logic if I’m wrong.

The code is:

namespace PRIMEWebFlyControl
{
  class Program
  {

    // name of the process we will retrieve a handle to
    private const string PROCESS_NAME = "PRIMEPipeLine";
    private static Process ProgramHandle;
    private static string command;

    static void Main(string[] args)
    {
        //Console.WriteLine("This program has been launched remotely!");
        TextReader tr = new StreamReader("C:\\inetpub\\wwwroot\\PRIMEWeb\\Executables\\FlyCommand.txt");
        command = tr.ReadLine();
        tr.Close();

        ExecuteCommand();
    }

    [DllImport("user32.dll")]
    static extern bool SetForegroundWindow(IntPtr handle);

    private static void ExecuteCommand() {
        if (AssignProcessHandle()) {
            IntPtr p = ProgramHandle.MainWindowHandle;
            SetForegroundWindow(p);
            SendKeys.SendWait(command + "~"); // "~" is equivalent to pressing Enter
        }
    }



    private static bool AssignProcessHandle()
    {
        // ask the system for all processes that match the name we are looking for
        Process[] matchingProcesses = Process.GetProcessesByName(PROCESS_NAME);
        // if none are returned then we haven't found the program so return false;
        if (matchingProcesses.Length == 0) return false;
        // else, set our reference to the running program
        ProgramHandle = matchingProcesses[0];

        // return true to indicate we have assigned the ref sucessfully
        return true;
    }

}
}

As you will notice the code contains method calls of Windows library methods like SetForegroundWindow() and as I am unfamiliar with batch files, I wondered how the same thing might be achieved.

Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:02:24+00:00Added an answer on May 23, 2026 at 6:02 am

    If I understand well, you are looking for a command line that will execute a bunch of commands that exist inside a text file named (C:\inetpub\wwwroot\PRIMEWeb\Executables\FlyCommand.txt)

    Here is what you need to do:

    cmd < C:\inetpub\wwwroot\PRIMEWeb\Executables\FlyCommand.txt
    

    In case the path contains spaces, use the following command:

    cmd < "C:\inetpub\wwwroot\PRIMEWeb\Executables\FlyCommand.txt"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read in some of the ClickOnce posts that ClickOnce does not allow
I have read that while plug-ins are not supported for SQL Server Management Studio,
I have read that it is a good practice to not use too many
I have read that using database keys in a URL is a bad thing
I have read that private variables in a base class are technically inherited by
Apparently I can't move files on different volumes using Directory.Move. I have read that
Everything I have read says that when making a managed stored procedure, to right
I have read a lot that LISP can redefine syntax on the fly, presumably
I have a read query that I execute within a transaction so that I
I have read on Stack Overflow some people that have converting to C#2.0 to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.