Hi everyone,
I have a VB Script that lists the installed programs and physical (disk,memory,cpu) attributes of a computer. It works completely well when i run it on my local machine and create outputs in ".txt" format.
I want to write a C# Application that will deploy my script to the servers on my local network and run it. Finally i need to get the results from those servers. To accomplish that, what configurations i have to do in my client servers and use which libraries or methods to implement a C# code.
If there are any tutorials or code samples, it will help me better to understand the concept.
(I work on Windows Server 2008 R2 Enterprice and i'm the administrator of the whole network (in fact, my clients are vmware hosts and each of them including my main server can ping each other:))
Sam HobbsPosted Feb 27, 2011, 4:43 PM
onur sananePosted Feb 27, 2011, 4:02 PM
So let me detail my question.
Firstly, what i want to do is sending a script from main server to its clients servers, run the sent script(script will give some result files) and take the result files to main server.
At first, i thought that i can do it with C# Form Application. I would create a GUI and had a button which will do what i mentioned above. If we look at the problem steps:
1) how can i send a file (ex my script file) to the client servers from a main server without installing any application to clients. If it is not possible without installing, is it possible to write another script to do this.
2) Let's consider script is successfully sent to client servers, how can i run it on client servers with a C# code. Again if it's not possible with C#, is there any way to do it with Visual Basic Script.
3)If we assume step 1 and 2 is completed, how can i get the result files in client servers to my main server.
My knowledge about C# is not bad but i'm not familiar with network applications like this; that's why i need your guideness. Sorry to take your time with this misunderstanding but i'm just seeking for an answer not bothering anyone.
Sam HobbsPosted Feb 27, 2011, 3:42 PM
I don't think you have told us how the script would be used in the sense that would it be executed autamatically by the task scheduler or would it be executed by the user of the workstation systems when they need to ("ad hoc") or whatever. That is relevant to the question of whether the script could be executed from the server and if that could be done then that makes a huge difference.
Jaganathan BantheswaranPosted Feb 27, 2011, 3:23 PM
Okey, fine.
As i know, can tell that we can create a c# application which will do two thimgs. First thing is to execute the VBScript and the second one is to copy the output file of the VBScript from client machine.
When you execute the Server C# Application it will execute the VBScripts and it will copy the output file to your server machine. I guess its possible and also it will work for you.
onur sananePosted Feb 27, 2011, 3:04 PM
(By the way, thanks for your quick replies.)
Jaganathan BantheswaranPosted Feb 27, 2011, 2:57 PM
Your are saying that " I do not need any third party application running on my client machine". Then there is no meaning to post this question in C# Language forum section.
As sam told, you may refer TechNet Script Center site.
onur sananePosted Feb 27, 2011, 6:54 AM
Let me clarify more what i want to do. I have a script and i want to deploy it to my clients on the network. One way to do is, of course, copying the script to all computers but i want to do it automatically. I will have a GUI and with a button in the GUI, my script will be sent to all client computers and will be run as a service or a simple process on the remote clients.
If i have to write again a script, where will i define the usernames and passwords, which classes i need to use, or will i have to change my /etc/hosts file on the server machine.
If i have to write a C# code, how can i do it with out installing any programs or codes to client servers. Setting up a TCP connection looks like a solution but i dont want an application that will run on client servers as a startup process or something like this.
All i want to do is running a script on remote servers without installing any third party applications to my clients. I can do anything in my main server and i have all rights to connect the remote hosts(passwd. username,ip etc.)
Sam HobbsPosted Feb 26, 2011, 4:20 PM
Jaganathan BantheswaranPosted Feb 26, 2011, 3:19 PM
I prefer to do this using Tcp Socket programming in C#.
Using socket programming you can send files to systems in your network.
Using Process class in C# you can execute the VB script.
So use this two logic, One machine should execute the VB script using C# Application and send the out put file to the another machine. the other machine should listen for the file and should receive it.
Thats it.
Have a look at File Transfer and Executing commands from the links.
http://www.c-sharpcorner.com/uploadfile/dottys/socketprogdtrp11222005023030am/socketprogdtrp.aspx
http://socketprogramming.blogspot.com/2007/11/file-transfer-using-c-socket.html
http://www.c-sharpcorner.com/UploadFile/DipalChoksi/ShellCommandsInCS12032005042031AM/ShellCommandsInCS.aspx
And also i have attached code for file transfer.