Solved

asp.net c# execute .bat server side problem

Posted on 2016-09-15
6
84 Views
Last Modified: 2016-09-16
Hello I followed this tutorial to execute a .bat from server side:

http://codebetter.com/brendantompkins/2004/05/13/run-a-bat-file-from-asp-net/

And works perfect if I use in that .bat files commands like "del", "move", "copy" and all the internal commands of the command prompt. However we want to use the command "ffmpeg" to compress videos in that .bat files and of course "ffmpeg" is not internal command and the asp.net does nothing and ignores the .bat command if we use "frmpeg" command. We suppose this is because "ffmpeg" is not a internal command or something like that we don't know. Like I mentioned before all works perfect if I use internal commands but not when I use any other command that are not from the OS like this case the "ffmpeg". How can we be able to execute commands like "ffmpeg" from that .bat files and with asp.net c#? Or why happens this issue of the .bat files are accepted only with internal commands when you execute via the asp.net?

I hope someone can help.

Thank you
0
Comment
Question by:Alex E.
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 250 total points
ID: 41800498
It may be a pathing issue.
EG instead of running ffmpeg try giving it the full path:
(EG: C:\Program Files (X86)\ffmpeg)

It could also be  a security issue.
The application will run the bat file under the app pool it's running (EG: if the application's pool is running under network service, that will be the user that runs the bat file).

Try granting ffmpeg's security and all related files (dlls and such) to "everyone".  Lastly ensure there are write permissions for the new files.
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 250 total points
ID: 41800870
Within the .bat file, are you using the start command to launch ffmpeg?
0
 

Author Comment

by:Alex E.
ID: 41800880
this is the specific command:

ffmpeg -i "%%~fa" -acodec aac -ac 2 -strict experimental -ab 160k -vcodec libx264 -preset slow -profile:v baseline -level 30 -maxrate 10000000 -bufsize 10000000 -b 1200k -f mp4 -threads 0 "%%~dpna.mp4"

Open in new window


no start at the beginning.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 41800934
does it run in the directory if you just run it normal?  

What if you log into the server using the app pool identity?
0
 

Author Comment

by:Alex E.
ID: 41801303
Yes if you run the .bat without the asp.net application runs perfect the .bat.

Exactly where and how can I log that? Because we went to event viewer and we don't see any special or is there any way to log this kind of things? how?
0
 

Author Closing Comment

by:Alex E.
ID: 41801424
I made it work executing the line in this form:

start /ABOVENORMAL /I /D "C:\inetpub\wwwroot\act\" ffmpeg.exe -i "%%~fa" -acodec aac -ac 2 -strict experimental -ab 160k -vcodec libx264 -preset slow -profile:v baseline -level 30 -maxrate 10000000 -bufsize 10000000 -b 1200k -f mp4 -threads 0 "%%~dpna.mp4"
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question