use ffmpeg in vb.net service application - vb.net

hi i want to write a vb.net application using ffmpeg . is there any possible way to run ffmpeg without putting ffmpeg.exe inside the application path or without any hardcoded path ?
Can Any hardcoded path of ffmpeg be used in windows service application ?
Process.Start("cmd.exe", "/k c:/ffmpeg/bin/ffmpeg.exe -i rtsp://198.168.1.40/cam -map 0:0 -map 0:1 -s -vcodec libx264 -g 60 -vb 500000 -strict experimental %03d.ts")

You can compile the FFmpeg libraries for Windows Runtime and link them.
There's a guide here:
https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT
Microsoft also released a FFmpegInterop library. This is useful for playback as it implements a MediaStreamSource.

If you don't include it with your application, wouldn't you necessarily have to provide a hard-coded path? I suppose you could add the path as an appSetting in your config file.
I include it as a resource in my assembly and reference it via the path from the application directory:
_ffmpeg = My.Application.Info.DirectoryPath & "\Resources\ffmpeg.exe"
It's similarly kicked off using Process.Start as you've noted, but by calling ffmpeg directly, rather than cmd.
Dim _FFmpegProcessPropertys As New ProcessStartInfo
_FFmpegProcessPropertys.FileName = _ffmpeg
_FFmpegProcessPropertys.Arguments = Params
_FFmpegProcessPropertys.UseShellExecute = False
_FFmpegProcessPropertys.RedirectStandardOutput = True
_FFmpegProcessPropertys.RedirectStandardError = True
_FFmpegProcessPropertys.CreateNoWindow = True
Dim FFmpegProcess = Process.Start(_FFmpegProcessPropertys)

Related

Download a (.exe) file through vb or cmd

I need a way of downloading a program through either visual basic or cmd. I have tried these, but the file after it's downloaded is only about 600 bytes and doesn't work. I own this website and have ftp access, if I download it through ftp it's fine. I'm using Visual Studio 2013 by the way. These are the methods I've tried:
CMD through VB:
Dim MyCmd, Ws, Ret
Ws = CreateObject("wscript.Shell")
MyCmd = "cmd /c Powershell.exe -ExecutionPolicy bypass -noprofile -WindowStyle Hidden (New-Object System.Net.WebClient).DownloadFile('http://minecraftmapmakerstool.16mb.com/downloads/The_Map_Makers_Tool.exe','C:\Users\user\Desktop\The_Map_Makers_Tool.exe'); Start-Process C:\Users\user\Desktop\The_Map_Makers_Tool.exe;"
Ret = Ws.run(MyCmd, 0, True)
VB:
My.Computer.Network.DownloadFile("http://minecraftmapmakerstool.16mb.com/downloads/The_Map_Makers_Tool.exe", "C:\Users\user\Desktop\The_Map_Makers_Tool.exe")
Thanks in advance :)
I think there is no built in tool in Windows that would do that for you. But there are plenty free programs on the web, that you can install and then call from your batch script. Here is one of them: CURL
Here is a basic example of how to use it (using your link)
#echo Off
Title
Pause
CD C:\Users\Jah\desktop
curl http://www.jah.com/ofac/downloads/t11sdn.pdf > download.pdf
This would download and save the file from the URL you have provided to download.pdf
Another possible alternative would be WGET.

How do I install this service_wrapper for mongrel/rails on my windows server?

I have been given the unpleasant task of installing a Rails 3 app I have written on Windows Server 2008 (definitely not my choice - was promised a linux server but I.T. pulled the rug out at the last minute so please don't suggest a change in environment as a solution).
I followed the instructions on this blog post (with a few minor modifications) and now actually have my app up and running under Windows/IIS (proxying mongrel) after a great deal of frustration. The only thing remaining is to get mongrel running as a service.
Unfortunately the mongrel gem has not been kept up-to-date for Rails 3 and while I can get the app running under mongrel at the command line I am unable to use mongrel_service to get the app running as a service.
The solution to this appears to be to use the service_wrapper project on github which has been mentioned in this previous question. The project is not yet complete but apparently functional but comes without documentation/binaries. I have looked through the source-code and don't really understand what is it/how it works so was wondering if someone can point me in the right direction (or, even better, walk me through how) to get this installed.
So close, yet still so far.....
Alright I have this worked out (with a little help from luislavena himself - thanks).
Download service_wrapper-0.1.0-win32.zip from https://github.com/luislavena/service_wrapper/downloads and extract service_wrapper.exe from bin/. I extracted it to C:\service_wrapper.
Next set up a configuration file. I used the hello example and modified it for my app then placed it in the C:\service_wrapper directory.
; Service section, it will be the only section read by service_wrapper
[service]
; Provide full path to executable to avoid issues when executable path was not
; added to system PATH.
executable = C:\Ruby192\bin\ruby.exe
; Provide there the arguments you will pass to executable from the command line
arguments = C:\railsapp\script\rails s -e production
; Which directory will be used when invoking executable.
; Provide a full path to the directory (not to a file)
directory = C:\railsapp
; Optionally specify a logfile where both STDOUT and STDERR of executable will
; be redirected.
; Please note that full path is also required.
logfile = C:\railsapp\log\service_wrapper.log
Now just create the service with
sc create railsapp binPath= "C:\service_wrapper\service_wrapper.exe C:\service_wrapper\service_wrapper.conf" start= auto
(watch for the spaces after binPath= and start=. It won't work without them)
Then start it with
net start railsapp
And you're home and hosed!
I ought to contribute due to this article. For config of using bundle exec, use the following:
Note that I am setting up rubyCAS! it's a great OpenCAS authentication mechanism!!!
; Service section, it will be the only section read by service_wrapper
[service]
; Provide full path to executable to avoid issues when executable path was not
; added to system PATH.
executable = C:\Ruby\bin\ruby.exe
; Provide there the arguments you will pass to executable from the command line
arguments = D:\rubycas-server bundle exec rackup -s mongrel -p 11011
; Which directory will be used when invoking executable.
; Provide a full path to the directory (not to a file)
directory = D:\rubycas-server
; Optionally specify a logfile where both STDOUT and STDERR of executable will
; be redirected.
; Please note that full path is also required.
logfile = D:\rubycas-server\log\service_wrapper.log

Is is possible to run cmd commands straight from VB

Is is possible to run cmd commands straight from VB. I want to be able to set up a command in vb without showing the black cmd window
path= C:\Program Files (x86)\Java\jre6\bin
java -Xmx1024M -Xms1024M -jar minecraft.jar nogui
Is it possible to run it without making a batch file? ( I want be be able to change some of the values in the commands to)
I found Shell(pathname[,windowstyle]) but I am not quite sure how to use it or if it is the right code.
You can use the Process class.
Dim pi As new ProcessStartInfo("C:\Program Files (x86)\Java\jre6\bin\java")
pi.Arguments = "-Xmx1024M -Xms1024M -jar minecraft.jar nogui"
Process.Start(pi)
I have use ProcessStartInfo to hold the process information before starting it off.
you can use Process.Start static Method
MSDN Link

Shell (pushd) behavior in vb.net

I am shelling in the a few push d statements based on a list of users from the active directory. 2 for example are
java.exe -version
and
dir /s
The search actually seems to search the actual computer and output the files from their directory. However, the java.exe only outputs the actual output from the computer that it is being ran on.
Is this even possible to run a remote exe from the pushd statement? Any thoughts would be great.
Here is the code as of right now in a simplified version. Let me know if anyone would like more.
Dim sCommand as String = "pushd \\***\C$ && java.exe -version 2>>C:\Testfile.txt"
Dim sCommand2 as String = "pushd \\***\C$ && dir /s blah.blah>>C:\Testfile.txt"
For each SelectedItem in Listbx.SelectedItems
Dim ReplaceCommand as String = sCommand.Replace("***", SelectedItem)
Shell("cmd.exe /c" & ReplaceCommand, True)
Dim ReplaceCommand as String = sCommand2.Replace("***", SelectedItem)
Shell("cmd.exe /c" & ReplaceCommand2, True, -1)
Next
To me, you'll need to find on the remote computer first the location of the JAVA executable. Your commands you're executing on the shell will search your local defined paths, not the remote paths.
Consider this.
first execution is local > running java 1.6.0.23
then I pushd to another computer. I re-execute the same command.
Since i'm not in the remote directory containing the java.exe file, it'll process my path to find it. >same version is returned
I then change to the remote's Java container and re-execute the statement.
This time it's finding the remote Java.exe and processes the command.

PSExec: How can I show a JPG file on a remote computer?

I need to start a document on a remote computer instead of an executable file, using PSExec.
I tried to provide the file name of a jpg file to psexec associated with the -c command to copy the file, but the message returned for documents (and not executables) is always "The system cannot find the file specified."
Anyone any ideas what the command-line for psexec should be?
Try to use the command:
cmd.exe /c START c:\path\to\document.jpg
Document must be on the remote computer, so you have to copy it there by other command before calling psexec.
Pick a program on that other machine that can show the JPEG and execute that, passing to it the path and name to the file you want to show.
As you've noticed, file associations doesn't work with remote execution like that, so you need to invoke the correct program instead.
In order to open a remote program and not only activate its process you have to use PSEXEC
with the -i (Interactive Mode) and MUST define the session number.
For example:
Usually on a Win7 host:
Console = Session 0
System = Session 1
User = Session 2
In order to activate and open notepad.exe on this remote Win 7 host use the following syntax:
psexec -i 2 \\ComputerName -u User -p Pass notepad.exe
Regards,
Shai Ziv
shaix.ziv#intel.com
This is the way that worked for me:
I've logged on to the via RDP:
I've copied a picture to the to "C:\Users<MyUserName>\Pictures\smiley.png"
I've opened a new powershell-window, typed "tasklist" and found out my windows session id (I simple took the highest session id I've found)
Back on my own PC:
I've downloaded PSTOOLS from https://download.sysinternals.com/files/PSTools.zip
I've unpacked PSTOOLS and placed it in "C:\Program Files\PSTools"
I've opened a new powershell-window and typed: cd "C:\Program Files\PSTools"
Finally i've started the remote PAINT with:
"C:\Program Files\PSTools\psexec" -s -i 4 "\\[RemoteComputerName]" "C:\Windows\system32\mspaint.exe" "C:\Users\[MyUserName]\Pictures\smiley.png"
P.S.: Don't forget to replace [RemoteComputerName] and [MyUserName]