|
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
|
|
|
|
|
tdcmystere wrote: 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.
We can abstract the question to "how do I get data from PC1 to PC2". The recommendation would be to look into WCF, but any type of exchange-mechanism would do- there's examples on communicating using sockets, but it'd even be possible using simple files.
Are the computers on the same LAN? If yes, I'd go for a simple socket
|
|
|
|
|
Thank you for response
Yes all Computers are nearly on the same network inside a Active directory.
it's about 9K of computers.
|
|
|
|
|
Make that a multithreaded client/server, based on TCP/IP. Alternatively, you can write files to an UNC-share - might be easier to code, will be a bit harder to maintain.
|
|
|
|
|
in my question i ask to provide me " shure if it possible" a little exemple how to pass a command and give back a response "data".
i don't ask a whole code i want to learn but a little help will be much appreciate.
Thank you
PS: sorry for my english
|
|
|
|
|
There's a client/server example on MSDN[^]. Be sure to check out the hyperlinks at the bottom of the page.
|
|
|
|
|
Thanks for this link, i already read this article, based on this, as i can understand is a console based server/client.
how i can whrite a simple command for server or client to get infos about printers.
for example i use this peace of code to retrieve local printers on a remote computer
private void GetPrinters()
{
string strServer = "\\\\" + this.textBox20.Text;
ConnectionOptions options = new ConnectionOptions();
options.Username = "xxxx";
options.Password = "xxxxx";
options.Authority = "NTLMDOMAIN:consilium";
ManagementScope myScope = new ManagementScope(strServer + "\\root\\cimv2", options);
SelectQuery oQuery = new SelectQuery("SELECT * FROM WIN32_Printer");
ManagementObjectSearcher oResults = new ManagementObjectSearcher(myScope, oQuery);
foreach (ManagementObject oItem in oResults.Get())
{
string strPrinterName = oItem.Properties["DriverName"].Value.ToString();
listBox2.Items.Add(strPrinterName.ToString().ToUpper());
}
}
i would like to execute this code on a remote computer and get the data back to my winform.
thank you in advance
|
|
|
|
|
tdcmystere wrote: i would like to execute this code on a remote computer and get the data back to my winform.
Then you will need to write something to do that communication, or use an existing solution
You could also adapt the console-example to suit your needs, hence the link. If that's too much trouble, then you'd have to map a network-drive from the server, and use a batch-file to write the result to a file on that network-share. E.g.;
MyCommand.exe > F:\thefile.txt
|
|
|
|