Jump to content

RunAsSet on another compiled AutoIT Script?


Recommended Posts

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()

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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:")

Link to comment
Share on other sites

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

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...