Jump to content

Writing to a file with elevated permissions


Recommended Posts

Hi All,

I'm in the process of creating an AutoIT file to run periodically on a local machine and set the local administrator password to a random value. The important part of the script is that it will run in the user context but needs to output the new password to a locked down share that only IT support have access.

I'm having issues writing to a file with the standard $file = FileOpen('' & $NetworkLogPath & @ComputerName & '.log', 9) function. I have tried running it with a RunAs function with an account with write permissions to the folder but still unable to create and write to the file.

Any pointers would be welcomed.

Thanks

Craig

 

Link to comment
Share on other sites

what error do you get?

p.s.
(not even to ask if your $NetworkLogPath variable ends with a slash "" of course)

Edited by PincoPanco

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Could always try to first DriveMapAdd the share, and then do the fileopen (that would get around the runas, since the rights are associated with the drive, and not the user running the script)...plus, DriveMapAdd returns a lot more @error data, for debugging.

I agree with PincoPanco, post the definition of those variables as well.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...