Jump to content

RunAsSet not passing credentials


Recommended Posts

Hi all,

I'm trying to get a script to copy a file to 30+ servers using a generic service account. I can run it fine using a domain admin acct, but for some reason its not passing the RunAsSet credentials using a generic user account. I even tried using domain admin credentials in it, but no luck.

Here is my script:

$file = FileOpen(@ScriptDir & "\servers_test.txt", 0)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

RunAsSet ("User1", "Domain2", "Password3")

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

FileCopy ( "\\server1\shared$\remodel.txt", "\\" & $line & "\n$\remodel.txt",1)

MsgBox(0, "File copied to: ", $line)

Wend

MsgBox(0, "Success", "Updated file successfully copied to all servers in the list.")

FileClose($file)

RunAsSet()

I also get an error when trying to run the following to check the logged in user:

Run(@ComSpec & ' /k echo %username% successfully logged in')

When doing a beta run, I get: The directory name is invalid.

Edited by Mondo327
Link to comment
Share on other sites

RunAsSet works with Run and RunWait commands, so far as I know. Try replacing your FileCopy command with this:

RunWait(@comspec & ' /c copy "\\server1\shared$\remodel.txt" "\\'& $line & '\n$\remodel.txt"',@scriptdir)

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

RunAsSet works with Run and RunWait commands, so far as I know. Try replacing your FileCopy command with this:

RunWait(@comspec & ' /c copy "\\server1\shared$\remodel.txt" "\\'& $line & '\n$\remodel.txt"',@scriptdir)

Thanks for the feedback. I thought RunAsSet might need to run an outside file during some deep thought this afternoon.

The RunWait script you suggest works for me as an admin, but I still need to pass elevated privs to a basic user to complete the copy.

I'm trying to get this compiled into a single exe file. I'd also like to get the servers.txt file compiled into the script as well so noone can change it.

Any other ideas?

TIA

Mondo

Link to comment
Share on other sites

Your RunAsSet command should work fine for basic users too. Give it a try. As for the servers.txt, take a look in the help file at the command FileInstall.

AHhhhhh.....I see now *said the blind man*.

I'm working on using fileinstall and filedelete to complete the script.

Thanks again

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...