Reputation: 41858
I need to have my unmanaged VC++ program able to copy a file from the computer the application is on to one of 100 other computers.
I have administrator access on each computer, so that won't be a problem.
It seems I need to use WMI to do this, but I am having a hard time getting it to work properly by looking at examples in: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394558(v=vs.85).aspx
I am curious of the CopyFile
family of functions should work:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363851(v=vs.85).aspx
This is a console application that doesn't use MFC and isn't using ATL.
Is there a good example of how to do what I am trying to do that will work on WinXP and Windows 7?
Upvotes: 0
Views: 1037
Reputation: 490148
The easiest way is probably to start by creating a network connection with WNetAddConnection2
, then copy the file with something like CopyFile
or CopyFileEx
. When you're done, it would be courteous to use WNetCancelConnection2
to remove the network connection.
Upvotes: 1
Reputation: 136401
The only WMI class designed to manipulate files is the CIM_DataFile
class, they include a set of methods (Copy, CopyEx) to copy files but only works in the target machine, this means which you cannot copy a file from one machine to another using the WMI (at least which you use a network drive or shared).
Upvotes: 1