1

Using C#, is it possible to iterate over a list of remote Windows computers connected to the LAN and turn on/off internet access for specific PCs only and while the internet connectivity is provided via a router? And all that without installing any client software on the remote PCs.

Rastaman
  • 73
  • 6
  • 1
    I'd have to say no... There's a reason people flood computers with traffic in order to take them offline; because this (for obvious reasons) is not possible. – Nahydrin May 11 '12 at 17:36
  • The thing you're looking for is `WMI`. But you need administrator account on given computer. – nothrow May 11 '12 at 17:37
  • @KirkWoll agreed. Also, are the computers remote or local? Don't mix `remote comcputers` with `LAN` in the same context. You definitely can't reach remote computers behind a router, but you can if they are on a LAN, provided you have administrative access on the other computer (@Yossarian). – Nahydrin May 11 '12 at 17:38
  • Computers would be remote machines with no client apps installed to facilitate the process. Admin rights also no problem (or a dedicated account with the rights to perform this action for that matter). – Rastaman May 11 '12 at 17:39
  • Hi, get Win32_OperatingSystem for a remote PC (on LAN as you gave hint) via WMI, and call Shutdown() or Reboot() methods (if you have rights to do that, of course). – SmartK8 May 11 '12 at 17:40
  • http://stackoverflow.com/questions/2921905/wmi-to-reboot-remote-machine – SmartK8 May 11 '12 at 17:41
  • @SmartK8 - thanks for the pointers, that's a start. I attempt to build a simple app that allows to turn on/off internet access on well-known Windows machines in a given LAN. I need to perform this action often on a router in our office. Why not just boot up this little app which list all PC's and just hit a checkbox to disable internet for the machine in question. – Rastaman May 11 '12 at 17:53
  • I'm glad I could be of any help. :) Maybe you should also look on http://software.bootblock.co.uk/?id=wakeonlanex2 it will even wake-up multiple computers, if they're turned off (but it would require you to set-up WOL on each of them). – SmartK8 May 11 '12 at 17:58
  • Ah, I looked up "mischievous". I was not aware that using the words "remote" and "LAN" in the same context can be confusing, indeed. With remote machines I simply meant PCs connected to the LAN except the machine hosting the to be written app. No wrong intentions here. – Rastaman May 11 '12 at 18:03
  • You can also check if the router u are using has an interface which listen to commands, then can you send the commands from a C# App to the router. – Svexo May 11 '12 at 18:07
  • If you're using a more *advanced* router, you could do this by sending a message to the router to block the internet from certain computers.. you'd probably have to custom write the web service on the router to handle it though – Earlz May 11 '12 at 18:20
  • @Svexo If it turns out a solution is too far stretched, I will fall back on your suggestion, assuming that our router has a command interface. Ideally I am hoping the current plan is feasible as I want to publish the results on codeplex.com. – Rastaman May 11 '12 at 18:22
  • @Rastaman As far as my knowledge goes, you have 2 Options, The first option I already mentioned the other is trough Sending a remote command tho the OS (Like the Remote Shutdown command), I'm not sure if their is such command to block internet. But bare 2 things in mind when choosing the last option, 1, Though its a remote command it also is partly client-side but is just by default in the OS and secondly when sending a command you can't send a command to the Remote PC the reconnect since their is no connection anymore. – Svexo May 11 '12 at 18:40

1 Answers1

1

This answer might better be served as a comment, but it is a little long to write there.

You should look into creating a Group Policy.

This is what our local Network Administrator does.

We have hundreds of PCs out on our production floor that have to connect to our network to access data over the local server and server at our remote plants.

These PCs access our network via a Public profile, which does not have Internet access.

We also employ multiple servers (applications server, mail server, web server, sql server, etc).

When the Public account is logged in, the router denies traffic to the web server.

If a manager or supervisor needs to look up a part out on the production floor, they can log in with their account (i.e. not the Public account) and access Internet information.

Lucky for me, you did not ask HOW to do this, because I am not really sure how this is done. You only asked if it was possible.

  • Although this answer gives some interesting insights into the matter, it does not address the question "Using C#, is it possible to turn on/off internet access for specific computers connected to the LAN", for example using a check box within an app installed on a single admin machine. – Rastaman May 12 '12 at 01:53
  • 1
    OK then. Yes, you can write an app for your server that controls the router, then enable functionality for your device to send and receive messages from that router. By this send and receive mechanism, you can populate a list on your device of the PCs connected and send a message back to the server to deny a PC's access. This would be a large and rather involved project, though. –  Sep 18 '12 at 14:35
  • 1
    The mobile device itself, however, would not be able to do this on its own. You will need to create the server tool that does this, then enable the functionality to allow the mobile device to use its features. –  Sep 18 '12 at 14:37