Solved

asp.net c# execute .bat server side problem

Posted on 2016-09-15
6
77 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.
  • 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
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
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…

860 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