Disconnect Internet when starting a program (TSR-type)

LDMN

New member
Joined
Jan 15, 2024
Messages
1
Programming Experience
5-10
Greets.

As a layman to modern computing and programming, wondering if you could post a source code for the subject problem.
Namely, would need to write and run a background program (oldie terminology: TSR), which is scanning if certain 3rd party programs (in Windows 10) are being launched. If yes, then it disconnects from Net / Wifi ( disables adapter temporarily, or sg like that) preferably without needing admin rights.

Thanx, Bye !
 
Unfortunately this is not a "gimme-the-codez" site, so we won't be posting code for your request.

This is a site can help you with the code that you write. If you tell us what problem you are running into, and share the relevant part of the code that is giving you problems, we can provide some help and advice.

Technically, in Windows, there is no Terminate-but-Stay-Resident. When an application terminates, the program is flushed out of memory, and all memory released, and OS handles it has open are closed. Windows is not like DOS where you can allocate a chunk of memory, point interrupt handlers into that chunk of memory, and then change memory limits to protect that allocated chunk.

Anyway in general, Windows would prefer that you install such a long running app as a Windows Service. Services run as long as the OS is running (or can be configured to be start on demand). I said prefer, because you could also just have your program start and then never terminate, but some people may consider your program misbehaving.
 
Last edited:
Greets.

As a layman to modern computing and programming, wondering if you could post a source code for the subject problem.
Namely, would need to write and run a background program (oldie terminology: TSR), which is scanning if certain 3rd party programs (in Windows 10) are being launched. If yes, then it disconnects from Net / Wifi ( disables adapter temporarily, or sg like that) preferably without needing admin rights.

Thanx, Bye !

As has been said, this does sound like a Windows Service. In DOS a TSR was used for device drivers. In Windows, services are used for device drivers. A service is something that executes without a UI. In early versions of Windows, services were allowed to have a UI, but not anymore.

For the purposes of monitoring what programs are executed, there is something called the Windows Management Instrumentation. I do not know Powershell much but you can probably write a Powershell script using WMI to monitor what programs execute. It would nearly certainly need to execute with higher privileges.

There are also software called Network Sniffers. Depending on requirements, something like that might help. A network specialist might be able to write a network analyzer that does what you need done.

Windows is not like DOS where you can allocate a chunk of memory, point interrupt handlers into that chunk of memory, and then change memory limits to protect that allocated chunk.
I probably misunderstand what you mean. To me, that sounds like things that device drivers do.
 
I probably misunderstand what you mean. To me, that sounds like things that device drivers do.

Yes, in DOS, because you needed a way for the TSR program to be kept "in-the-loop" about events happening in the OS. Like the most common DOS TSR's would be activated by a key press. It somehow has to see all the key press interrupts go by.

For Windows, there is a distinction between a device driver, a filter, and a Windows Service. A device driver is often at the lowest levels -- some still running in kernel mode despite all of Microsoft's efforts to push drivers to run in user mode -- and talk to the devices directly. For the kernel mode drivers, interrupts are sent to them directly. For user mode drivers, the OS provides a thunking layer where the interrupt goes to the OS in kernel mode, and then the OS routes the messages to the user mode side. Filters can examine the stream of data and commands going to and from the devices and the OS. A Windows service need not necessarily be a device driver -- it can be using the same user mode APIs that normally use a application developers. Yes, there are services that work intimately with device drivers and filters, but a service need not be tied to servicing device needs. Consider these Windows services that typically run a desktop and/or server: Windows logon, Windows Update, Google Update, Windows Installer, Task Scheduler, Print Spooler (as opposed to print drivers), font cache, SQL, IIS, FTP, SMTP, ASP.NET State Service, background intelligent transfer service.

How to write a Windows Service using the traditional .NET Framework way:

And the newer .NET (Core) way:
 

Latest posts

Back
Top Bottom