Sign in to follow this  
Followers 0
JBassman

No Luck searching

4 posts in this topic

OK folks, I haven't had any luck in my searches today so I am posting. I am trying to run some file related calls as another user. However, it seems that I am not getting back what I need from my RunAs call. I have included a sample code below as to what I am trying to do. I have checked all file permissions and shares on my end and those are working properly, so I am assuming I have a syntax issue or something. Anyhow, any help with this would be greatly appreciated. Thanks in advance, and now the code. :)

#include <File.au3>
#Include <Array.au3>
$username = "AppUser"
$domain = "domain"
$password = "P@ssW0rd1"
$Photo_Dir_Loc = "\\servername\sharetoaccess\"

$FileList = Runas($username, $domain, $password, 2, _FileListToArray($Photo_Dir_Loc)) ; <-- This returns a No Folders Found error.
;$FileList = _FileListToArray($Photo_Dir_Loc)  ; <-- This will work as expected.

If @Error=1 Then
MsgBox (0,"","No Folders Found.")
EndIf
If @Error=4 Then
MsgBox (0,"","No Files Found.")
EndIf
_ArrayDisplay($FileList,"Files")

Please ask any questions and I will try to answer them as best as possible.

Share this post


Link to post
Share on other sites



See the description of Runas: "Runs an external program under the context of a different user."

You can't run AutoIt functions as another user. You have to run the whole script.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

*Face Palm*

Sorry for that. So I would need to run the entire script as the other user? How would I go about such? Can you point me to an example, and I can take it from there.

Share this post


Link to post
Share on other sites

Wouldn't it be easier to connect to the server using "NET USE" as the other user, run the _FileListToArray and then disconnect?

The program in runas could be something like

@ComSpec & " /c " & 'net use ...'

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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
Sign in to follow this  
Followers 0