Jump to content
Sign in to follow this  
Chewie71

RunAsSet on another compiled AutoIT Script?

Recommended Posts

Chewie71

Hiya,

I've written a couple scripts with AutoIT. The first is a logger script(LogonLOG.exe) that appends some data onto a log file on the server. The log files cannot be read or written to by normal users...so...I created a logger user with permissions to the log file and wrote a second AutoIT script (called from a VB logon script) that does a RunAsSet on the first logger script. Both scripts are compiled into EXEs. Does not seem to work though. Any suggestions??? Should I be doing this another way?

LogonLOG.exe Script

*****

$filePClog = FileOpen(@logonserver & "\logs$\PC\" & @computername & ".log", 1)

$fileUSERlog = FileOpen(@logonserver & "\logs$\USER\" & @UserName &".log",1)

FileWriteLine($filePClog, "Log In :: " & @MON&"/"&@MDAY&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC & " :: " & @UserName)

FileWriteLine($fileUSERlog, "Log In :: " & @MON&"/"&@MDAY&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC & " :: " & @ComputerName)

FileClose($filePClog)

FileClose($fileUSERlog)

RunLoggers.exe Script

*****

; Set the RunAs parameters to use logger account

RunAsSet("loggeruser", @LogonDomain, "loggeruserpassword")

If $CmdLine[1] = "LOGON" Then

Run(@logonserver & "\NETLOGON\VBSFiles\LogonLOG.exe")

ElseIf $CmdLine[1] = "LOGOFF" Then

Run(@logonserver & "\NETLOGON\VBSFiles\LogoffLOG.exe")

EndIf

; Reset user's permissions

RunAsSet()

Share this post


Link to post
Share on other sites
Chewie71

Nope...checked that already. If I MsgBox out that Run line it comes out with the \\ already in front.

Just to be sure I edited in the "\\"& like you show and ended up with \\\\logonserver\etc...

Thanks though...

Matt

Share this post


Link to post
Share on other sites
Chewie71

Here's the actual error I get, but I don't know if it will help...

Line 0 (File "\\servername\netlogon\vbsfiles\LogonLog.exe"):

FileWriteLine($filePClog, "Log In :: " & @MON&"/"&@MDAY&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC & " :: " & @UserName)

Error: Invalid file handle used.

Share this post


Link to post
Share on other sites
Chewie71

Looks like I get the same error, and on the second line my "MsgBox" returns error 5. When I run it locally on my PC it seems to be working fine. Put it on the server and call it from the logon script though and I get the errors. Well, enough for tonight, I'll try again tomorrow...thanks.

New LogonLOG.exe

************

DriveMapAdd("S:", @logonserver & "\logs$")

MsgBox(0,"ERROR",@error)

$filePClog = FileOpen("S:\PC\" & @computername & ".log", 1)

$fileUSERlog = FileOpen("S:\USER\" & @UserName &".log",1)

;$filePClog = FileOpen(@logonserver & "\logs$\PC\" & @computername & ".log", 1)

;$fileUSERlog = FileOpen(@logonserver & "\logs$\USER\" & @UserName &".log",1)

FileWriteLine($filePClog, "Log In :: " & @MON&"/"&@MDAY&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC & " :: " & @UserName)

FileWriteLine($fileUSERlog, "Log In :: " & @MON&"/"&@MDAY&"/"&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC & " :: " & @ComputerName)

FileClose($filePClog)

FileClose($fileUSERlog)

DriveMapDel("S:")

Share this post


Link to post
Share on other sites
Chewie71

Is there another way to do this? All I want to be able to do is write to a log file that the user doesn't have rights to. If there's an easier way I'm definately open to it.

Thanks,

Matt

Share this post


Link to post
Share on other sites
Chewie71

Got it...had to add '2' to the end of the RunAsSet line...then it worked. Don't have to map the drive either...straight UNC. Can you explain why it works with the '2'? Was it trying to find and use a local account called 'loggeruser' instead of the domain account?

RunAsSet("loggeruser", @LogonDomain, "loggeruserpassword", 2)

Thanks,

Matt

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.