Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to start a bat file on remote computer when i log on using rdp.in mstsc,the program
settings is like this:
program path and file name is "e:\rdp\rdp_test\copy.bat"
e:\rdp\rdp_test\copy.bat is a bat file on remote computer.the contents of copy.bat is
"ping 10.2.1.1 >> .\ping.txt"

but when i log on the remote computer ,the bat file does not work and i dont find ping.txt.
how can i solve this program ?
thanks !
Posted
Updated 4-May-15 22:14pm
v2
Comments
Sergey Alexandrovich Kryukov 5-May-15 0:52am    
Why? why?!
—SA

1 solution

It makes no practical sense. Two things: 1) ping is ping, it can be done on any computer, either the host of RDP client or server; so there is no need to "ping remotely"; 2) there is no need to run any batch file to ping.

Let's see. You can ping any computer system running the service supporting the ICMP protocol. That means nearly all non-nonsense systems participating in networking. Please see:
http://en.wikipedia.org/wiki/Internet_Control_Message_Protocol[^],
http://en.wikipedia.org/wiki/Ping_%28networking_utility%29[^].

You did not explain what system did you try to ping, the host of your RDP service, client, or some other one, so your logic is hard to understand. I can say one thing: whatever it is, this logic would like quite weird to me. Perhaps you can explain. No matter; this is how you can ping any system from anywhere: https://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping%28v=vs.110%29.aspx[^].

This way, you don't need to crack unnatural riddles. :-)

As the active part is, as always, the client part, most likely you need to add the ping functionality on the client, which is, by the way, easier to do, because you can always implement custom RDP client, which is simple enough. You can review some existing implementations, such as those two from CodeProject:
Palantir - Remote Desktop Manager[^] (my favorite),
Remote Desktop using C#.NET[^].

—SA
 
Share this answer
 
Comments
libin0410 5-May-15 4:13am    
i dont think you understand what i want to do. the ping bat file is just an example,and the bat file can be executed successfully on remote computer. we can change 10.2.1.1 to 8.8.8.8 as well or change the bat file to which can contains other dos commands. what matters is just starting a bat file. as for Palantir - Remote Desktop Manager[^] and Remote Desktop using C#.NET , i have already read these two projects.
Sergey Alexandrovich Kryukov 5-May-15 10:18am    
I did not understand it because you did not explain anything properly. Where did you say "it was just an example"?
And where is your answer to my question — why? What is your purpose?
—SA
libin0410 5-May-15 11:04am    
sorry about that , my english is not very well .my purpose is like this:
1: connect to remote computer using rdp protocol.
2: run a bat file on remote computer .the bat file contains a lot of dos commands which can get much information about the remote computer. the ping bat file is just a example. i can change its contents to "echo 123 >> text.txt".
3: move the results file text.txt from remote computer to local computer.
that is my purpose. i want to realize my purpose using c#,and make this application not in gui. but i dont know how to realize it. i have done some examples using Palantir ,Remote Desktop using C#.NET. but my application is just in gui and i dont realize start ing a program and move file from remote computer to local. as for starting a program ,i try mstsc.exe and set program path and file name to "e:\rdp\rdp_test\copy.bat",but it does not work. that is all .thanks anyway !
Sergey Alexandrovich Kryukov 5-May-15 11:16am    
As I understand, you need to run the batch on the remote computer, where the RDP service is running. I'm afraid you would need alternative RDP implementation. And then, the question would be: why RDP? It could be some other application-layer protocol of your own. :-)
—SA
libin0410 5-May-15 12:00pm    
well,it is a demand of my project。it has to be realized in rdp。

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900