Page 1 of 1

External Programs - Parameters

Posted: Sun 22 Feb 2015 1:15 am
by BCJKiwi
With Cumulus1 I used batch files in external programs for a number of purposes.

I have refined this activity for MX as batch (.cmd) files open a live windows command shell taking focus from whatever you may be doing.
I still have one .cmd file, daily.cmd which;
runs an FTP program to send dayfile.txt to the public website,
copies dayfile.txt to the LAN webserver,
copies (with date selection) NOAA files to the LAN webserver.

Am testing two solutions to run daily.cmd hidden;
1. vbs

Code: Select all

 ' daily.vbs
' Runs daily.cmd in a new hidden command shell ( the '0' ).
' references - https://msdn.microsoft.com/en-us/library/d5fk67ky.aspx
' Note, if there is a pause or other 'feature' which stops the execution of the .cmd file,
'       the hidden shell will be left running but doing nothing.
'       Use Task manager to close it.

' invoke shell . Run "this command", hide, wait for command to finish then close hidden shell
CreateObject("Wscript.Shell").Run "C:\CumulusMX\FTP\daily.cmd", 0, True
Wscript.Quit
This seems to work OK with full_path_to/daily.vbs in the external programs slot - no parameters required.
2. chp.exe This is a small program available here http://www.commandline.co.uk/chp/ you only need the chp.exe program from the download package. This works great from the command line with chp.exe in the same folder as daily.cmd. This also will be left hanging if the batch file fails to complete.
However I am unable to work out how to get this working in the external programs slot(s).
The command line that works is;
full_path_to/chp.exe daily.cmd where chp.exe and daily.cmd are in the same folder.

Both these approaches have the advantage that the daily.cmd file can be run directly if required.

As it takes a day for each alternative in external files to be tested properly any assistance in how external files/parameters work would be much appreciated.

Re: External Programs - Parameters

Posted: Sun 22 Feb 2015 8:42 am
by steve
"full_path_to/chp.exe" is the command and "daily.cmd" is the parameter - does that not work?

Re: External Programs - Parameters

Posted: Sun 22 Feb 2015 9:51 am
by BCJKiwi
Thanks,
"full_path_to/chp.exe" is the command and "daily.cmd" is the parameter
That is what I expected but it did not work last night.
I will try it tonight with the full path to daily.cmd as well. I presume the quotes are not required? They are not when just calling daily.cmd directly nor when calling daily.vbs.

Re: External Programs - Parameters

Posted: Sun 22 Feb 2015 10:08 am
by steve
It looks like I am actually causing the window to be opened when the command is run, and I can change it so that (in theory at least) it doesn't do that. That would make things simpler.

Re: External Programs - Parameters

Posted: Sun 22 Feb 2015 11:12 am
by BCJKiwi
Yes, that would be preferable to running extra 'hide me' tricks.

I can confirm that the chp.exe and daily.cmd combo with full path for each (no quotes) has just run as expected.

So, if you don't/can't make the external programs run without launching a new command shell, then we will have two options for doing it hidden (vbs and chp) as outlined in the first post.

Thanks

Re: External Programs - Parameters

Posted: Sat 02 May 2015 9:44 pm
by BCJKiwi
Have updated the .vbs script in the first post by adding
Wscript.Quit
on a new line at the end.

Found there were cmd and wscript left running in task manager.
Wscript.Quit appears to have stopped that.