Page 1 of 1
Programmer's help needed !
Posted: Tue 11 Feb 2014 5:54 am
by laulau
Hi,
I've written a little VB application that monitors my central heating device through a PLC.
It produces log files and runs an extenal program at each 'realtime', 'logtime' and rollover as Cumulus do.
The code i use to run the external batch:
but i've a little problem:
Each time the external program runs it opens a little "Command line window" (closed automaticaly) but it's very annoying when you're doing something on the same computer.
Question : is there an other instruction i can use or some options to hide the "Command line window" ?
Thanks
Re: Programmer's help needed !
Posted: Tue 11 Feb 2014 7:21 am
by uncle_bob
laulau wrote:
Question : is there an other instruction i can use or some options to hide the "Command line window"
Yeah there is, but I can't for the life of me, remember what it is as it's been 10 years since I mucked with DOS

Re: Programmer's help needed !
Posted: Tue 11 Feb 2014 8:25 am
by nitrx
Re: Programmer's help needed !
Posted: Tue 11 Feb 2014 10:28 am
by BCJKiwi
Does the info here help?
http://www.developerfusion.com/article/ ... -function/
1. Shell without the call
2. vbHide
Just a guess, my VB skills <=0 !
Re: Programmer's help needed !
Posted: Tue 11 Feb 2014 11:07 am
by laulau
@ BCJKiwi
I'll it this evening.
@ Steve
How do you manage the external programs call in Cumulus (pascal) ?
Re: Programmer's help needed !
Posted: Tue 11 Feb 2014 1:01 pm
by steve
laulau wrote:@ Steve
How do you manage the external programs call in Cumulus (pascal) ?
I use a wrapper to
ShellExecute, like this:
Code: Select all
Res := ShellExecute(MainForm.Handle, nil, PChar(prog), PChar(Params), nil, 0);
Re: Programmer's help needed !
Posted: Tue 11 Feb 2014 5:45 pm
by laulau
Hi,
Changed
to
No more annoying windows

et Merci
Now i'm going to write a ftp subroutine to upload my log files, for the moment Cumulus is doing this job perfectly

I certainly need some more help to achieve that
I'll start by googling on this topic!
Re: Programmer's help needed !
Posted: Tue 11 Feb 2014 7:38 pm
by BCJKiwi
If you can live with Windows' built in simple FTP, then you can add that to your batch file. If not you can add a command line FTP program (e.g. NcFTP available here at no cost).
http://www.ncftp.com/ncftp/
Click download, scroll down to download NcFTP Client and in the section Precompiled binary distributions
Select the "NcFTP Client 3.2.5 for Microsoft Windows" link.
This will download an .msi package and initiate an installation.
It installs the .exe' s into %windir% so all you need to do is call ncftpput. There will be shortcuts and documentation in c:\program Files\NcFTP Software\
Syntax is a bit finicky but this is fast and robust. It will also generate logs if you want.
Re: Programmer's help needed !
Posted: Tue 11 Feb 2014 9:39 pm
by laulau
Is ncfp more efficient than windows ftp command line ?
I also found the option to use
Code: Select all
Public Sub UploadFile(ByVal _FileName As String, ByVal _UploadPath As String, ByVal _FTPUser As String, ByVal _FTPPass As String)
Dim _FileInfo As New System.IO.FileInfo(_FileName)
If _FileInfo.Exists Then
' Create FtpWebRequest object from the Uri provided
Dim _FtpWebRequest As System.Net.FtpWebRequest = CType(System.Net.FtpWebRequest.Create(New Uri(_UploadPath)), System.Net.FtpWebRequest)
Try
' Provide the WebPermission Credintials
_FtpWebRequest.Credentials = New System.Net.NetworkCredential(_FTPUser, _FTPPass)
' By default KeepAlive is true, where the control connection is not closed
' after a command is executed.
_FtpWebRequest.KeepAlive = False
' set timeout for 2 seconds
_FtpWebRequest.Timeout = 2000
' Specify the command to be executed.
_FtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
' Specify the data transfer type.
_FtpWebRequest.UseBinary = True
' Notify the server about the size of the uploaded file
_FtpWebRequest.ContentLength = _FileInfo.Length
' The buffer size is set to 2kb
Dim buffLength As Integer = 2048
Dim buff(buffLength - 1) As Byte
Try
' Opens a file stream (System.IO.FileStream) to read the file to be uploaded
Dim _FileStream As System.IO.FileStream = _FileInfo.OpenRead()
' Stream to which the file to be upload is written
Dim _Stream As System.IO.Stream = _FtpWebRequest.GetRequestStream()
' Read from the file stream 2kb at a time
Dim contentLen As Integer = _FileStream.Read(buff, 0, buffLength)
' Till Stream content ends
Do While contentLen <> 0
' Write Content from the file stream to the FTP Upload Stream
_Stream.Write(buff, 0, contentLen)
contentLen = _FileStream.Read(buff, 0, buffLength)
Loop
' Close the file stream and the Request Stream
_Stream.Close()
_Stream.Dispose()
_FileStream.Close()
_FileStream.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message, "Upload Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Catch ex As Exception
MessageBox.Show(ex.Message, "Connect Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
in my VB application.
Does anyone have an opinion on this

Re: Programmer's help needed !
Posted: Wed 12 Feb 2014 3:10 am
by BCJKiwi
Is ncfp more efficient than windows ftp command line ?
NcFTP package just a suggestion - it has been around a long time and is very robust. Has a lot more features but is a little more tricky to set up than the windows built in FTP. However windows FTP works well enough if you just want simple. You could start with that and move to something more sophisticated later if required. I only suggested it as you already have a batch file so why not use some well developed and bullet proof command line FTP instead of 'rolling your own'.
Re: Programmer's help needed !
Posted: Wed 12 Feb 2014 4:33 pm
by Karv
if you have a batch job, you can just call an FTP script to move files about, they are as simple as
Code: Select all
open <ip address>
username
password
cd /<directoy>[optional]
put filename [or mput *.extension or get or mget]
bye
call this from your batch script as
ftp -i -s:<path/to/ftpscript>
