简体   繁体   中英

copy VBS from local to remote machine and execute it

I need to copy and execute a .vbs script from my local machine to a remote machine from a C# program.
I tried using psexec but it seems that it is unable to copy the vbs file to a remote machine.
I'd rather not copy the file with net use (and then execute it with psexec ).
The Remote machine is protected by a username and password.

Can you think on an elegant solution to copy and execute the script?

Thanks

I struggled with psexec for a long time, but I could not get it to work 100%. Sometimes it would pop up a EULA message (you are meant to be able to get rid of this with a command line option), sometimes it would not work at all. I ended up created a WCF web service that I install and run on the remote machine; the web service will execute command lines that I send to it, such as a command to run batch/script file.

Of course such a service is open to hacking and abuse, so you want to make sure you only use it in safe and protected environment, or you use appropriate authentication on the web service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM