I need to connect to a computer in LAN
and to open CMD in the remote computer
and send a command (for example ping www.google.com - but other commands..)
I thought to open a server on the remote computer and a client in my computer and every time to send a command as a string to the server side, and to send that command to the cmd (i know it's easy with c++)
is there another way to do this?
is there a way in vb6 to open cmd in a remote computer and to send a command?
the reason i write this here is because the client side will be written in vb6
the client is not written, but i will put it in a program written in vb6
thank you
You might be able to use WMI. You could copy over a batch file, script or an executable and then use WMI to execute it remotely.
You can use Win32_Process.Create as described here: Creating Processes Remotely
You could use Psexec from SysInternals and avoid writing anything for the server side.
You could also use telnet/ssh.
Related
Our team has ~80 Windows development machines, and activities of each developer are logged as text files on the local storage of those machines.
To analyze the logged activities, I want to gather all log files from those machines. Additionally, the log files are updated constantly, so It is desirable to gather files with the command-line from my machine.
I’ve searched and found some solutions, but all of those are not suitable for our situation:
We cannot use PsExec, because tcp/135 and tcp/445 are both closed (countermeasure for WannaCry).
Administrative share is disabled.
telnet service is not up and is banned by security reasons.
WinRM is disabled on those machines by default.
It is difficult to install new software like OpenSSH on those machines (because of the rule of this project)
RDP is the only way to connect those machines. (I have an account on all machines)
How can I copy files from remote Windows machines with command-line through RDP?
Or, at least, is there any way to execute a command on remote Windows machines with command-line through RDP?
I think you can do this, though it is very hacky :)
For a basic setup, which just copies files once, what you would need to do is
Run a script in the remote session when it logs in. I can think of three ways to do this:
Use the "Alternate Shell" RDP file property. This runs a specified program in place of explorer.exe on login; you can use it to run "cmd.exe /c [your script]" for instance.
If that doesn't work (e.g. the remote machine doesn't respect it), you might be able to use a scheduled task that runs the script on login, but perhaps only for a specified user, or maybe the script could check the WinStation type to make sure this is actually an RDP connection before doing anything.
It's also possible to do this by connecting in RemoteApp mode and using the script as your "application", but that only works for Server and Enterprise editions of Windows.
Enable either drive redirection or clipboard redirection on the RDP connection, to give you a way to get data out.
Drive redirection is much simpler to script; you just have the remote script copy files to e.g. "\\tsclient\C\logs".
Clipboard redirection is theoretically possible - you have the remote script copy, then a local script paste - but would probably be a pain to get working in practice. I'm only mentioning it in case drive redirection isn't available for some reason.
You would probably want to script to then log the session off afterward.
You could then launch that from command-line by running "mstsc.exe [your RDP file]". The RDP files could be programmatically generated if needed (given you're working with 80 machines).
If you want a persistent connection you can execute commands over, that's more complicated, but still technically possible. Two ways I can think of:
Use the previous method to run a program on logon, but this time create a custom application that receives commands using a transport that isn't blocked and executes them in the session. I've done this with WCF over HTTP, for instance; it's not secure, of course.
Develop and install a service on the remote machine that opens an RDP virtual channel, and a corresponding RDP client plugin that communicates with it. You can then do whatever you want across the connection. While this solution would be the most likely to work, it's also the most heavyweight and time-consuming to implement so it's probably a last resort.
Right now I am using winscp to manually copy files from unix server to my windows desktop.
I Would like to automate the same by running some script in unix.
Can someone please help?
-Sajith
The simple answer is: run an FTP server on Windows and write a simple FTP client script on Unix.
For Windows, you can use
IIS (built in to all versions of Windows, but switched off by default)
Filezilla -- free https://filezilla-project.org/download.php?type=server
one of the many proprietary FTP server programs. See http://en.wikipedia.org/wiki/List_of_FTP_server_software
At the Unix end, write a script to control the built in FTP client.
Another answer is: use IIS on Windows as a file uploader/downloader by writing a really simple Web site. Use wget or curl at the Unix end.
Another answer is: implement SAMBA on Unix, so that it joins your local Windows network. Copy files using standard shell commands.
Another answer is: use Dropbox and transfer files via the cloud.
I could probably think of more, but that's enough.
I am trying to work on a old script of mine that I was writing to backup file on my VMware server.
Originally the script was going to run on Linux only, but now I trying to figure out how to make it run on Windows. Most of the modules I need for perl will run on Windows and Linux which is good. But there is one module that I can't seem to find, which is an SSH module.
My plan was to use putty or plink to send commands to the server and return them to the script. But the problem that I see is every time I call putty in the script its going to open new connection to server and close it when it has finished. What I am looking for is a way to open a connection once its open leave it open and then send and receive from that one connection. Only having it close when the script calls a close function or something.
Any idea where I could being with something like this?
Unless someone else has a much better idea because I am open to anything.
There's quite a few SSH client modules from CPAN, such as Net::SSH, Net::SSH::Perl, and Net::SSH2.
You can also try using Expect
http://metacpan.org/pod/Expect
I have an application running only on Windows and a batch file that launches it.
I want to invoke this batch file from Linux, meaning something like Linux batch will launch the windows batch with parameters and this in its turn run my application.
Can I do that? How?
You could install an ssh server in the windows box (Cygwin has one), then from linux do something like:
ssh user#windows-box c:/path/to/batch.cmd
and that should launch your application in the windows box.
The most direct way is probably to install an ssh server on the windows box. Cygwin includes an ssh server.
Depending on how precise your timing needs are, you might be able to have an "at" job on the windows box that runs periodically (every 5 minutes?) and runs if it sees that a particular file exists, deleting the file. Then you could use Samba/smbclient to create the file. You would need to turn on filesharing on the windows box for this to work.
If the windows box has a web server, you could write a CGI, and trigger it using wget or cURL.
Our build process currently goes the other way: a windows sever kicks off things on the Linux server using plink (part of PuTTY). You might be able to set something similar up.
This may cause a security issue. Our information security person did not allow me to invoke any programs directly.
The safer way is to set up server on Windows computer. This can be a web-server for example. And then invoke your process inside PHP/Perl/Python script.
Also look at winexe that allows you to execute windows commands/batch scripts without running ssh server.
I'm writing a simple executable in C that needs to open a putty session and send commands to it, then close putty. I can open/close the putty session (i'm not that bad) but i'm not too sure on how to send putty the commands.
Any ideas??
From the PuTTY FAQ:
How can I use PuTTY to make an SSH
connection from within another
program?
Probably your best bet is to use
Plink, the command-line connection
tool. If you can start Plink as a
second Windows process, and arrange
for your primary process to be able to
send data to the Plink process, and
receive data from it, through pipes,
then you should be able to make SSH
connections from your program.
This is what CVS for Windows does, for
example.
Plink can use PuTTY's saved sessions in addition to opening sites directly.
PLink's options are documented in Chapter 7 of the PuTTY manual.
Use the DLL, Luke. http://www.winputty.com/
Have you looked at the source for QuickPutty? It's LGPL licensed.