southboyj Posted January 7, 2010 Share Posted January 7, 2010 (edited) I want to be able to copy a file from a share the user will have full control of to the C$ share of another computer which they will need to enter admininstrative credentials for. I don't want to map a drive. The problem is that RunAs doesn't see the FileCopy function as a program. I'm sure there is something smple I am overlooking. Script is below. Thanks ;Variables $UserID = InputBox ("User", "Enter Administrative Account", "", "") $Password = InputBox ("Password", "Enter Password","", "X") $Domain = InputBox ("Domain", "Enter Domain","" , "") $ComputerName = InputBox ("Computer", "Enter Computer Name or IP Address","", "") RunAsWait ($UserID, $Domain, $Password, 0, FileCopy ('\\ServerName\ShareName\FileName.cmd', '\\' & $ComputerName & '\c$\', 1), "", @SW_HIDE, "") Edited January 7, 2010 by southboyj Link to comment Share on other sites More sharing options...
omikron48 Posted January 7, 2010 Share Posted January 7, 2010 (edited) That is because FileCopy is an AutoIt function and not a program. RunAsWait expects a program parameter to run, which is not what it is getting. Where do you intend to run the script? Which computer, your's, the user's, a third computer? You could try: RunAsWait($UserID, $Domain, $Password, 0, "copy \\ServerName\ShareName\FileName.cmd \\$ComputerName\c$\", "", @SW_HIDE) No guarantees though. Edited January 7, 2010 by omikron48 Link to comment Share on other sites More sharing options...
southboyj Posted January 8, 2010 Author Share Posted January 8, 2010 That is because FileCopy is an AutoIt function and not a program. RunAsWait expects a program parameter to run, which is not what it is getting. Where do you intend to run the script? Which computer, your's, the user's, a third computer? You could try: RunAsWait($UserID, $Domain, $Password, 0, "copy \\ServerName\ShareName\FileName.cmd \\$ComputerName\c$\", "", @SW_HIDE) No guarantees though. Thanks. Will try that. The script will be run from local computer copying a file from a remote server to a remote computer. Link to comment Share on other sites More sharing options...
southboyj Posted January 8, 2010 Author Share Posted January 8, 2010 Actually I tried: ;Variables $UserID = InputBox ("User", "Enter Administrative Account", "", "") $Password = InputBox ("Password", "Enter Password","", "X") $Domain = InputBox ("Domain", "Enter Domain","" , "") $ComputerName = InputBox ("Computer", "Enter Computer Name or IP Address","", "") RunAsWait($UserID, $Domain, $Password, 0, "copy \\Servername\Sharename\Filename.cmd \\" & $ComputerName & "\c$\", "", @SW_HIDE) and received the same results. Any other thoughts Link to comment Share on other sites More sharing options...
whim Posted January 8, 2010 Share Posted January 8, 2010 @southboyj try RunAsWait($UserID, $Domain, $Password, 0, @ComSpec & " /c copy \\ServerName\ShareName\FileName.cmd \\$ComputerName\c$\", "", @SW_HIDE) HTH, whim Link to comment Share on other sites More sharing options...
southboyj Posted January 8, 2010 Author Share Posted January 8, 2010 It doesn't work.RunAsWait($UserID, $Domain, $Password, 0, @ComSpec & " /c copy \\ServerName\ShareName\FileName.cmd \\$ComputerName\c$\", "", @SW_HIDE)The $Computername variable above in BOLD is not recognized as a variable when entered like this. Link to comment Share on other sites More sharing options...
whim Posted January 8, 2010 Share Posted January 8, 2010 LOL, yeah, missed that. AutoIt will not recognise vars within a string, so maybe this will work: RunAsWait($UserID, $Domain, $Password, 0, @ComSpec & " /c copy \\ServerName\ShareName\FileName.cmd \\" & $ComputerName & "\c$\", "", @SW_HIDE) Link to comment Share on other sites More sharing options...
southboyj Posted January 8, 2010 Author Share Posted January 8, 2010 I have a workaround that may be acceptable... I create a script that contains FileCopy and I right-click and do a RUNAS from Windows. Worked like a champ. Thanks for playing.... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now