Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

copy file to remote computer from local with credentials

$
0
0

 I am using windows XP

I want to copy a file from my system to another system(XP) through WMI.

I don't have admin rights to that system.so i want to use credentials..

 

There are many sample program regarding this but they don't meet my needs//

 

The FileSystem object's copy method don't have the feature of giving credentials..

 

WMI Program..

wbemImpersonationLevelImpersonate = 3
wbemAuthenticationLevelPktPrivacy = 6 

Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer _
    ("B1", "root\cimv2", "UserName", "Password")
objService.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
objservices.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy

 

Set colFiles = objWMIService.ExecQuery  ("SELECT * FROM CIM_DataFile WHERE  WHERE Name = " _
& "'c:\\scripts\\toggle_service.vbs'")
For Each objFile in colFiles
 strCopy = "c:\rr\"
objFile.Copy(strCopy)
Next

 

In this sample program,If i connect to B1 through WMI with credential then i was able to move only B1(remote) file to A1(local) Computer.. I want to move from local(A1) to remote(B!).. If i want to do that i am not able to give credentials..

Please help me with a program to move a file from local(A1) to remote(B1) by giving credentials for B1.

 

 


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>