WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: blint on September 24, 2021, 09:47:33 AM

Title: Can a Windows application interop with a WinBatch program?
Post by: blint on September 24, 2021, 09:47:33 AM
I am trying to find a way to prevent a Windows .NET application from running if it detects that it is running on a Citrix virtual desktop. (Licensing issues, nothing against Citrix.) I was directed to WinBatch Terminal Extender wtsIsCitrixEnabled() as a possible solution to this problem but I'm completely unfamiliar with WinBatch. If I were to use WinBatch, could I produce a DLL with  functions that could be invoked by the .NET Windows Application, and could the WinBatch function return values to that Windows application? A simple integer or boolean would suffice. 
Title: Re: Can a Windows application interop with a WinBatch program?
Post by: td on September 24, 2021, 04:33:48 PM
Guessing that you can't modify your .Net application. If that is the case then your options are limited. You could possibly create a compiled WinBatch script that launches your app after checking for Citrix. The WinBatch script could use the extender and function you mention to determine whether or not to start the app.
Title: Re: Can a Windows application interop with a WinBatch program?
Post by: kdmoyers on September 25, 2021, 09:07:48 AM
If you *can* add some code to your application, then I do this kind of thing all the time --  I compile together a winbatch program to do a certain crazy thing, then call that exe from within my ancient ERP system, and then collect the simple integer return value.  ( using intcontrol(1000,p1,0,0,0)  )  Almost any platform will let you execute a command line and collect the return value.

If I need a more complex return values, the simple solution is a text file in the TEMP folder.  Klunky, but if you are not doing it very often, is there much difference between a 1000th of a second and a 10th of a second?