1

I have a script with which I can scan the network for live ips and the result is being sent to a file called "ip_list.txt". After that, I would like to send a file "file.txt" on every ip address from the ip_list.txt and put it on a specific folder to each user pc. (ex. c:\temp) I was thinking about the use of WMIC command but I would like your help here...

Be noted that the admin password is known and the 135 TPC port is oppend on every client.

Moreover, which might be the differences of the above command if I wanted to be valid on both a domain or a Workgroup use?

1
  • Can you confirm if your case requires the need for the file to be placed regardless of whether the computers are on a domain or not?
    – Kinnectus
    Jan 6, 2016 at 14:00

2 Answers 2

0

Send a file to all network users automatically via WMIC command

I have a script with which I can scan the network for live ips and the result is being sent to a file called "ip_list.txt". After that, I would like to send a file "file.txt" on every ip address from the ip_list.txt and put it on a specific folder to each user pc. (ex. c:\temp)

You can use FOR /F to iterate through the values in the "ip_list.txt" file to then do an XCOPY to the hidden C$ share of all the PCs and then followed by the folder path where you want to copy that onto the "C" drive of each PC (i.e. C:\Temp is equivelant to (\\<ip address>\C$\Temp).

Give it a shot and see how it goes but I'd suggest testing this with just one or two IP addresses (once workgroup and one domain) inially in the "ip_list.txt" file and confirm that it works as expected.

The access on each PC would need to be enabled to complete this via the method below, your account it's run as would need to have access to the machines to do this (e.g. domain admin for domain PCs and local admin for the workgroup PCs perhaps).

You may have to embed credentials into the process for some of the IP addresses, but see how this goes and let me know. I'll update my answer with more detail if you have trouble, etc.

Example Command Prompt Run

(Note that the below example is a command prompt copy and paste type deal below and not a batch script, but I can change to run as a batch script if needed as well.)

FOR /F "TOKENS=*" %%A IN (c:\path\ip_list.txt) DO XCOPY /F /Y "C:\Path\file.txt" "\\%%~A\C$\Temp\"

Additional Resources

1
  • Thank you @LMFAO_A_JOKE!! Can you change your example to run as a batch script.. It would be very helpful to me..
    – castil
    Jan 6, 2016 at 16:59
0

If you're using WMIC then you're using Windows clients... scripting such a task sounds very inefficient to me when there are better tools out there to do the job...

If your computers are on a domain then you can force a file to be placed into your desired folder using Group Policy.

Group Policy can be configured to apply to any or all of your domain joined Windows computers. You can also tell the Group Policy to add the file once, replace the file if it exists (if the file contents need to be updated from a network share, for example) or delete the file if it no longer needed.

1
  • Thank you @BigChris for your answer!!! I know that it is easy with Group Policy but I just wanted to create a script doing those "jobs" without using any other tools or software..
    – castil
    Jan 6, 2016 at 16:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .