Author Topic: Can a Windows application interop with a WinBatch program?  (Read 137 times)

blint

  • Newbie
  • *
  • Posts: 1
Can a Windows application interop with a WinBatch program?
« 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. 

td

  • Tech Support
  • *****
  • Posts: 3947
    • WinBatch
Re: Can a Windows application interop with a WinBatch program?
« Reply #1 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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

  • Sr. Member
  • ****
  • Posts: 434
Re: Can a Windows application interop with a WinBatch program?
« Reply #2 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?
The mind is everything; What you think, you become.