VB exe and batch file question.

G

Guest

hi,
I have this situation here,
I need to call a VB application (which i can code), which does some
calculations on some dates and returns a date value.
For simplicity lets say, i pass a date to the VB app as command line
arguments, my vb app should return me a date 15 days earlier.
I will call this vb app from a batch file, how do i return a date value from
the VB app and assign it to a variable in my dos batch script, so that i can
use the returned date value for some actions to be performed.

Thanks for any responses.
--
Kannan.V
Home : http://www.kannanv.com
Blog : http://kannanv.blogspot.com
Web : http://www.DotnetLounge.net

"Any one who has never made a mistake has never tried anything new" - Einstein
 
D

Dragon

Hi,

There's API that might help you:

Private Declare Auto Function SetEnvironmentVariable Lib "kernel32.dll"
( _
<MarshalAs(UnmanagedType.LPTStr)> ByVal Name As String, _
<MarshalAs(UnmanagedType.LPTStr)> ByVal Value As String _
) As Boolean

I assume you can guess how to use it. 8=]
However, this function sets envvar only in calling process, so if you
call your .bat from your app it will work, but when aplication exits,
variable will be lost.

Another approach:
You can set the registry key at HKEY_CURRENT_USER\Environment and then
send WM_WININICHANGE message to HWND_BROADCAST with lParam equals to
"Environment", so each application will reload envvars. Though, I
haven't tested this, and you will get permanent envvar.

One more way:
You can use exit code of your application; set it via
Environment.Exit(code), and retrieve as %ERRORLEVEL%. However, it won't
work in Win9x, since there's no %ERRORLEVEL% variable.

Hope this helps a three little bits. 8=]

Roman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top