Csharp running batch file Issue

Hi,
I'm trying to run a batch file on the server using an asp.net csharp webpage. After I execute below code  the batch is not showing that it is running and the webpage is not throwing an error.
Here is the code in the webpage button :
string str_Path = Server.MapPath(".") + "\\TLogExecutor.bat";
            ProcessStartInfo processInfo = new ProcessStartInfo(str_Path);
            processInfo.UseShellExecute = false;
            Process batchProcess = new Process();
            batchProcess.StartInfo = processInfo;
            batchProcess.Start();

------------------------------------------------
Here is the batch file code :
PSEXEC -accepteula \\tlog-server "e:\Sched_Processes\TLogExecutor_Launch_Rerun.bat" > D:\Inetpub\wwwroot_2\TLogStatus\Log.txt

Please notice that Batch file is trying to run another batch on another server ?
Any suggestions ?

Thanks
ankounyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Does the account you're running your web page (app pool) as have permissions on the other server? PSExec will use the account that is executing it if you do not specify a username and password for the remote machine.
0
ankounyAuthor Commented:
How do I know which account it is running or using ?
0
käµfm³d 👽Commented:
If you haven't assigned an app pool specifically, then it is most likely using the default app pool and running as the ASPNET user. It might be easier for you to create a service account on the remote machine and pass the username and password in the command line. However, this could be a security concern. You may want to do this, though, so that you can test that it actually works. If it works at that point, you can go back and fiddle with your IIS user accounts to avoid having to pass credentials on the command line.

By "command line" I am referring to the "PSEXEC..." line you have in your batch file.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

ankounyAuthor Commented:
If I go now to the server and run this batch file manually, it works, but when I run the Csharp code above it wont run and it wont throw an error.
0
käµfm³d 👽Commented:
Right. When you log into the server, you are not using the ASPNET user; you are using, most likely, your account. You probably have an account on the remote machine as well (or you are a member of a domain and you are registered on that machine). When you log into the local server and run PSExec, your credentials are sent to the remote machine to confirm that you have an account there (or on the domain).
0
ankounyAuthor Commented:
Your right, I'm trying to login using my domain name credentials, but I 've also added in the security properties of this batch file the aspnet user to read and execute but it is not executing ...
Should I schedule the batch file to run through SQL server and then I call SQL serevre job through the web page ? is it a good idea to do this ?  
0
käµfm³d 👽Commented:
You have to understand how PSExcec works. Giving the web-site's user rights to execute the program is one thing; having rights on the remote machine is another thing. You either need to pass a username and password to PSExec in the batch file or you need to run your web-site as a user that has rights on both machines.

For more info on PSExec, see: http://technet.microsoft.com/en-us/sysinternals/bb897553 , particularly the blurb under "program arguments."
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.