Jump to content

Recommended Posts

Hi,

I am trying to upload file from local machines into remote network path.

If I use the same as FileCopy($Source, $Destination, 1) it works only for me. But for others it will require access to upload files. But RunAs is not working. Is my command incorrect?

Global $UserID = "username"
Global $Domain = "domain"
Global $Password = "password"
Global $Source = "C:\Test\Test.log"
Global $Destination = "\\Server Folder Path"

RunAsWait($UserID, $Domain, $Password, 0, @ComSpec & " /c copy " & $Source & " " & $Destination, "", @SW_HIDE)

 

Share this post


Link to post
Share on other sites

@Marc, thanks for quick response. I figured that the issue was with the destination folder and filename which had spaces. For some reason if there is space is folder or file structure it won't copy. It works without any spaces.

But it works from command line, not from the code. So users will not have access to the location which is why I am specifying the account credentials which will have. Should I be using 2 or 4 here?

Global $UserID = "username"
Global $Domain = "domain"
Global $Password = "password"
Global $Source = "C:\Test\Test.log"
Global $Destination = "\\Server_Folder_Path"

RunAsWait($UserID, $Domain, $Password, 0, @ComSpec & " /c copy " & $Source & " " & $Destination, "", @SW_HIDE)

Share this post


Link to post
Share on other sites
RunAsWait($UserID, $Domain, $Password, 0, @ComSpec & ' /c copy "' & $Source & '" "' & $Destination &'"', @TempDir, @SW_hide)

Try this one. Should fix it :)

Or the  the visible solution where you can read the result message:

RunAsWait($UserID, $Domain, $Password, 0, @ComSpec & ' /k copy "' & $Source & '" "' & $Destination &'"', @TempDir, @SW_show)

 


It's my job to comfort the disturbed and to disturb the comfortable.
My Projects: Profiler, MakeSFX, UserInfo

Share this post


Link to post
Share on other sites

It says "Incorrect Username or Password". But I know the credentials are correct.

Share this post


Link to post
Share on other sites

@Marc, I tried both of your solution too but still says "Incorrect User name or Password".

Just to let you know the destination path is Intranet Destination.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites
8 minutes ago, spudw2k said:

What is the source you are copying from?  I assume a Windows share (SMB/CIFS)?

 

Source is local machine.

Destination is Internal Network location.

Share this post


Link to post
Share on other sites

Does the account you are using have rights to the local machine?

If the account is for the destination only, try using $RUN_LOGON_NETWORK  for the logon_flag parameter.


Share this post


Link to post
Share on other sites
4 hours ago, spudw2k said:

Does the account you are using have rights to the local machine?

If the account is for the destination only, try using $RUN_LOGON_NETWORK  for the logon_flag parameter.

Yes, the account has rights to both the local machine and network path. That's why command line parameter is able to copy files but not via the autoIT code.

Share this post


Link to post
Share on other sites

Is it not possible to avoid the runaswait then and just run the script with the desired user?

The fact that the runaswait is giving an access denied tells me the account perms are wrong somewhere.

It's hard to troubleshoot without the full picture, so I apologize for redundant questions, but are you positive that the account has permissions on the source folder?

What about my earlier question?

12 hours ago, spudw2k said:

If you do a manual test using a cmd prompt and the runas tool, does it work?

runas /user:domain\username cmd.exe

copy source dest

 


Share this post


Link to post
Share on other sites
3 hours ago, spudw2k said:

Is it not possible to avoid the runaswait then and just run the script with the desired user?

The fact that the runaswait is giving an access denied tells me the account perms are wrong somewhere.

It's hard to troubleshoot without the full picture, so I apologize for redundant questions, but are you positive that the account has permissions on the source folder?

What about my earlier question?

 

I used my own credentials which has admin rights to both local machine and Network path. That's why running the command line from Windows CMD works with no issues but I am not sure why it says "Incorrect User name and password" from AutoIT command line.

The only reason I am using RunAsWait is my creds will not have admin rights to other users machines and eventually I will be using some elevated accounts. But the process and command line will be the same.

Also to let you know, the destination path is a SharePoint site library. I tried looking for other solution to add / upload files from local to SP but there was not much found. Which is why I had to go via the RunAsWait command line to get it simply as File copy method.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...