my question pertains to the use of the netcat utility ( i believe the developer is Hobbit) in windows.
i am using this utility (this is for a project and i must use netcat (no other solution))

i am using this utility in a batch file to put a file onto a remote computer

i am using it as such:
on the local computer
type f:\diagsfile.txt | nc %ip_add1% 1234
where diagsfile.txt is the text file i'd like to port to the nc (netcat command) at ip address %ip_add1% on port 1234

on the remote computer i use:
nc -l -p 1234 >diagsfile.txt

so on the remote computer netcat (nc) opens a listening port which will accept input and put it into the diagsfile.txt file locally

what my question is .... is there a way to eliminate the second step, either by logging into the remote computer using credentials(probably via netcat), or by stealth putting it on the remote computer ...

i'd like to eliminate the second step of opening the port and have to do the execution only on the initiating computer

all this is ( of course ) taking for granted that the firewall is turned off

thanks in advance

solution must be scriptable(batch file)
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gerwin Jansen, EE MVETopic Advisor Commented:
Sending a file over a tcp port to another computer will not work. As there is nothing 'listening' on the remote side, the file cannot be sent over. This would have been not very nice if someone using nc (or other tool) would just be able to put any file on your system.
David Johnson, CD, MVPOwnerCommented:
use sysinternals pscexec to execute a program on the destination computer

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
btanExec ConsultantCommented:
You can also check the remote for any shared folder (can find using ShareEnum) and dump the file into it
e.g using powershell (uses network share path to copy the file)
copy-item -Path d:\Shared\test.txt -Destination \\server1\Shared
OR (below but this may not work if you are trying to trying to access a network resource in a different domain.
New-PSDrive -Name X -PSProvider FileSystem -Root \\MyRemoteServer\c$\My\Folder\Somewhere\
cd X:\
cp ~\Desktop\MyFile.txt .\
## Important, need to exit out of X:\ for unmounting share
cd c:\
Remove-PSDrive X
Invoke-Command -ComputerName \\server -ScriptBlock {
  $args[0] | Set-Content  C:\Shared\test.txt
  } -ArgumentList (Get-Content D:\Shared\test.txt -Raw)
Other like mentioned using psExec and also net use e.g.
psexec -i -d -u user -p password \\client cmd "/C net use x: \\server & c:\program.exe"
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Digital Forensics

From novice to tech pro — start learning today.