DrLarch Posted December 22, 2023 Share Posted December 22, 2023 I have a scheduled task that runs as the local SYSTEM account (runs whether user is logged in or not and run with highest privileges is selected). The problem is trying to access files on a network share that requires authentication. I'm trying to find a way to do this but can't seem to authenticate out from the SYSTEM environment and copy files from the share. From what I understand, this is by design in Windows security. I've tried using the DriveMapAdd function before accessing and this as well: RunWait(@ComSpec & " /c " & 'net use "\\myserver\data" /USER:domain\user pass', "", @SW_HIDE) If FileExists($sSourceDir & $sINIFileName) Then FileCopy($sSourceDir & $sINIFileName, "C:\test\" & $sINIFileName, 1) RunWait(@ComSpec & " /c " & 'net use /delete \\myserver\data', "", @SW_HIDE) RunWait(@ComSpec & " /c " & 'klist purge', "", @SW_HIDE) EndIf And: $sCMD = 'copy ' & $sSourceDir & 'example.ini c:\ah\example.ini' RunAsWait("user", "domain", "password", 1, $sCMD, "", @SW_HIDE) But these all fail. I've tried the RunAsWait command with all four login flags but nothing works. When using interactive (1) I can see that the user is loaded under c:\users, but it still can't copy the files. These commands work when running a command as SYSTEM (via psexec) but it must be inheriting my user environment when logged in: net use "\\myserver\data" /USER:domain\user pass copy \\myserver\data\file.txt c:\test\file.txt net use /delete \\myserver\data klist purge I could try using psexec as well but I'm trying to avoid relying on external apps. And the windows runas.exe app requires interactive authentication, so that won't work either. Is there any way to do this natively within an Autoit script? I know this is more of a Windows security question, but any help would be appreciated. Link to comment Share on other sites More sharing options...
orbs Posted December 23, 2023 Share Posted December 23, 2023 instead of using the local SYSTEM account, create a dedicated account with sufficient rights in both local target directory and server share. if this is a domain environment, that should be quite easy. if this is a workgroup, it is only slightly less simple - you'll need to create an account on the server and use it for the server access, while using the local dedicated account to run the task. you can make that account invisible in Windows logon screen, if that troubles you. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Solution Nine Posted December 23, 2023 Solution Share Posted December 23, 2023 Another solution could be to use Task Scheduler UDF and create a task on the fly to run your network connection process... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
spudw2k Posted December 24, 2023 Share Posted December 24, 2023 On 12/23/2023 at 4:48 PM, orbs said: if this is a domain environment, that should be quite easy. ^ Agreed. If operating in a domain environment, you can set permissions to allow the computer account (COMPUTER$) to have permissions to the folder, and avoid storing user credentials; either explicitly, or a using security group (*preferred). 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 Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool 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...
DrLarch Posted January 8 Author Share Posted January 8 Thank you for the responses. Due to the security we have, I think that's the only way I'm going to be able to pull this off. I was hoping to be able to avoid a separate script run under another task but oh well. I wasn't familiar with the task scheduler UDF, so I'm going to check it out. I've used commands via Runwait and xml files to create new scheduled tasks, so I'll see how the UDF works. Thanks again 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