|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Invoking Copy From WMI between connections?
The following snippet of code is where I am at in trying to get a program (I'm using C#) to copy files from one computer to another.
Does anyone have an example of invoking a copy method from the managementobject between two different connections? I'm assuming I will need to set up a connection to the target computer using the username and password, but am not sure how to set the target path nor copy the files to it... -----Code Snippet------ StringBuilder sbQuery = new StringBuilder(); ConnectionOptions oConn = new ConnectionOptions(); //new ConnectionOptions(); //** User LAN Account and password used to start oConn.Username = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() ; oConn.Password = userPassword; try { System.Management.ManagementScope oMsSrc = new System.Management.ManagementScope("\\\\" + "myserversource" + "\\root\\cimv2", oConn); if (sbQuery.Length > 0) sbQuery.Remove(0, sbQuery.Length); sbQuery.Append("SELECT Name, CreationDate, Description, FileType, FileSize FROM CIM_Datafile "); sbQuery.Append(@"WHERE PATH = '\\prodload\\' AND Drive = 'c:'"); System.Management.ObjectQuery oQuery = new System.Management.ObjectQuery(sbQuery.ToString()); ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMsSrc,oQuery); ManagementObjectCollection oReturnCollection = oSearcher.Get(); //loop through each file int nRowCount = 0 ; //** just a row counter string sTest = ""; //** just a debug string holder foreach( ManagementObject oReturn in oReturnCollection ) { nRowCount++; sTest = oReturn["Name"].ToString(); //** this is just for me to see each file name at this point //** This is where the Invoke Copy would be done? } //** each objext } //** Try catch { } Any direction would be of help 8) Thanks, Bob |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > .Net Development > Invoking Copy From WMI between connections? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|