Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C#.net and Batch Files

Options
  • 29-06-2007 11:03am
    #1
    Registered Users Posts: 357 ✭✭


    Can I run a batch file from c#.net webpage and if so how do i do it
    cheers


Comments

  • Registered Users Posts: 357 ✭✭apoch632


    Oh yeah. can you pass paths into the batch files from the c#.net page cheers


  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    Google returns 917,000 hits on 'c# run batch'.


  • Registered Users Posts: 604 ✭✭✭Kai


    Howdy, best way to find something out is to search Google.

    I searched for "c# batch file"

    Second link was this http://www.thescripts.com/forum/thread224268.html


  • Registered Users Posts: 604 ✭✭✭Kai


    beat me to it Tom :)


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    In fairness to apoch632 he is asking how to run this from a webpage which may introduce difficulties. I've used code from the the example given http://www.thescripts.com/forum/thread224268.html (which is for winforms, not asp.net) to execute a batch file on my local dev machine.

    However, my dev server runs under my account and my account and local admin privilages. You do seem to be able to do this but I'd say they'll be rights issues in a production environment.

    What exactly are you trying to do apoch632? You may be able to do it from code instead of a batch file.


  • Advertisement
  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Actually I'll take that back, I seem to be having rights issues with this as well. So the code didn't work after all. My mistake.

    I would say that executing something on the server through a web page is difficult to do and difficult for a reason: You shouldn't be doing it. So tell us what you want to achieve and we'll work something out.

    BTW folks this -> report.gif is the report post button. If you have a problem with somebody's post then use it.


  • Registered Users Posts: 357 ✭✭apoch632


    Right I have 3 servers
    lets callled them a,b and c

    A is where an internal website is stored
    .
    I want to be able to copy (by clicking a button on the website)an ISO from b to c and vice versa.

    I've tried coding this in c#.net and cant get it working. I got all the rights permissions i need and it still wasnt working

    However if i use xcopy on the command line on server b to c or c to b it works fine. Also logged on server a xcopy works fine

    So i figured i'd use a batch file and run xcopy from there. Just wasn't sure how to get it working in c#.net

    Sorry about the above post it was just i'm in a bit of a rush to get this working


  • Registered Users Posts: 604 ✭✭✭Kai


    Can you post up some of the code your using to do this? What error message do you receive if any ?

    The website is going to execute the batch under the IIS user account which may not have access to B and C.


  • Registered Users Posts: 357 ✭✭apoch632


    I can post it on Monday.

    Its on a different computer


  • Registered Users Posts: 981 ✭✭✭fasty


    If you've got MS SQL 2005 on the same server you could install a .Net assembly with the appropriate permissions to work with System.Diagnostics.Process but it's a pain to set up.

    If you want to get something up and running in the mean time and again have MS SQL server I guess you could call the .bat file via xp_cmdshell in the master database... But I'm pretty sure if I did that in a live environment I'd get fired.


  • Advertisement
  • Registered Users Posts: 2,781 ✭✭✭amen


    of you could create a ms office object and use the command property to fire a batch file


  • Registered Users Posts: 357 ✭✭apoch632


    I got it working with a batch file over the weekend. Thanks for your help. Sorry my posts were a bit incoherrent. I was under pressure to have this done. Thanks for your help guys


Advertisement