Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 143
  • Last Modified:

asp.net c# execute .bat server side problem

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
Alex E.
Asked:
Alex E.
  • 3
  • 2
2 Solutions
 
Kyle AbrahamsSenior .Net DeveloperCommented:
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
 
käµfm³d 👽Commented:
Within the .bat file, are you using the start command to launch ffmpeg?
0
 
Alex E.Author Commented:
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!

 
Kyle AbrahamsSenior .Net DeveloperCommented:
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
 
Alex E.Author Commented:
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
 
Alex E.Author Commented:
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

Technology Partners: 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!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now