DigDeep Posted May 20, 2019 Share Posted May 20, 2019 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) Link to comment Share on other sites More sharing options...
Marc Posted May 20, 2019 Share Posted May 20, 2019 Untested, but according to the help: " It is important to specify a working directory the user you are running as has access to, otherwise the function will fail. " Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
DigDeep Posted May 20, 2019 Author Share Posted May 20, 2019 @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) Link to comment Share on other sites More sharing options...
Exit Posted May 20, 2019 Share Posted May 20, 2019 Change /c to /k to see error messages App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Marc Posted May 20, 2019 Share Posted May 20, 2019 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) Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
DigDeep Posted May 20, 2019 Author Share Posted May 20, 2019 It says "Incorrect Username or Password". But I know the credentials are correct. Link to comment Share on other sites More sharing options...
DigDeep Posted May 20, 2019 Author Share Posted May 20, 2019 @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. Link to comment Share on other sites More sharing options...
Marc Posted May 20, 2019 Share Posted May 20, 2019 (edited) strange. Tried it with our test user, works fine... UNC pathes work, too. No idea why you get the error message. Edited May 20, 2019 by Marc Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
spudw2k Posted May 20, 2019 Share Posted May 20, 2019 What is the source you are copying from? I assume a Windows share (SMB/CIFS)? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
spudw2k Posted May 20, 2019 Share Posted May 20, 2019 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 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
DigDeep Posted May 20, 2019 Author Share Posted May 20, 2019 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. Link to comment Share on other sites More sharing options...
spudw2k Posted May 20, 2019 Share Posted May 20, 2019 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. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
DigDeep Posted May 20, 2019 Author Share Posted May 20, 2019 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. Link to comment Share on other sites More sharing options...
spudw2k Posted May 21, 2019 Share Posted May 21, 2019 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 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
DigDeep Posted May 21, 2019 Author Share Posted May 21, 2019 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. 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