Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 C#3.0 C# C#4.0
Hello all,
 
I'm new here and it's a first time that i ask for help to the community. I'm also new in C sharp but i try to manage and learn on the way.
 
I would like to have some help to understand how to write a Process for windows with wich i can communicate with my winform.
 
i made an winform application which permit me to retrive some data from Active directory and also some other data from computers on the network "using powerShell" and a AD class.
 
For some reasons i can't grab a correct information about ex: shared Printers, cose the PowerShell give me a output of the computer printers, not user printers. It was a simple exemple.
 
so i decide to write a Process wich i want to upload and install on a remote computer, till here i can manage that.
 
what i would like to understand and if you can show me a little exemple, it's how to add some functions to this process and get the output of this function back to my Winform.
 
as exemple:
 
1.in my Winform a make a remote call to the process and ask him to give me the list of all printers installed.
2. show the output in a lisbox for exemple.
 

I would like to tell you thank you in advance for you help
Posted 19-Nov-12 3:25am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Two ways:
 
You can create a web service that retrieves the printers when the endpoint is called and returns them to the caller. This is nice because it is easy, there are lots of available examples, and it would have a high chance of success. The drawback is that you must have a web server on the machine (there is one built into windows) and you may have a security issue if the web service runs as the web server user and tries to access protected information like the installed printers.
 
Alternately, setup a socket listener in a windows service and listen for a remote connection returning the printers when requested. The drawback to this is that you may have to interact with Windows firewall and you have to deal with the possibility that your service may be shutdown either inadvertently or on purpose (user disables the service). If you are inside a company firewall you can mitigate a lot of these problems with group policy and automated deployment. There is also security concerns here too as the process will run as the service account or an account you specify on the target machine and if not crafted with security in mind, it could allow some sort of remote exploit. Of course, this won't work outside the firewall. (Something like web sockets/SignalR might though) Look at network chat applications as an example of communicating over sockets.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 445
1 Maciej Los 238
2 OriginalGriff 229
3 Zoltán Zörgő 190
4 BillWoodruff 120
0 OriginalGriff 7,969
1 DamithSL 6,139
2 Sergey Alexandrovich Kryukov 5,449
3 Maciej Los 5,309
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100