Avatar of mahmood66
mahmood66
Flag for United Arab Emirates asked on

Running exe(Application) from another machine via windows service

Dear Experts,

        i need to know the way how i can run an exe(application) which is located in another machine(Server) via windows Service by using VS2008 C# or VB.net

Note:
        service should run in both XP and Windows 7 also

kindly suggest me the code.

thanks
C#Windows 7

Avatar of undefined
Last Comment
kaufmed

8/22/2022 - Mon
kaufmed

You could use PSExcec from SysInternals. Just make sure to either pass the credentials of an account which exists on the remote machine, or run your service using an account that exists on both machines.
mahmood66

ASKER
Dear kaufmed,

Can you give me the Example code in C# how i can use this "PSExec"

thanks
Easwaran Paramasivam

Follow the second method in the below given artilce.

http://motevich.blogspot.com/2007/11/execute-program-on-remote-computer.html
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
mahmood66

ASKER
Dear Easwaran,

Thanks for your suggestion. couldn't able to use that code which you suggested.
Can you give me example code in C# ?
tell me which namespace and class i need to import to use " Win32_Process Class" & "Win32_ScheduledJob Class"


Note:
             my application should interact with client machine's  Desktop where my service runs.

Thanks
Easwaran Paramasivam

ASKER CERTIFIED SOLUTION
Easwaran Paramasivam

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
kaufmed

Can you give me the Example code in C# how i can use this "PSExec"
using System.Diagnostics;

namespace _27387473
{
    class Program
    {
        static void Main(string[] args)
        {
            Process.Start("psexec.exe", "\\remoteserver -u remoteusername -p remotepassword app_to_run.exe app_args1 app_args2");
        }
    }
}

Open in new window

Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.