orion156 Posted July 7, 2008 Share Posted July 7, 2008 I can't get the loginname with @Username, when I use #requireadmin in an AutoIt-script. In stead it shows the admin-username that I used to allow the execution. How can I get the first/original loginname? Link to comment Share on other sites More sharing options...
Airwolf Posted July 8, 2008 Share Posted July 8, 2008 I can't get the loginname with @Username, when I use #requireadmin in an AutoIt-script. In stead it shows the admin-username that I used to allow the execution. How can I get the first/original loginname?There is no built-in way to do it, but you could use _ProcessListProperties() to search through processes to find out who's logged onto the machine. Dim $array $array = _ProcessListProperties() For $i = 1 To $array[0][0] If Not StringInStr($array[$i][3], "Administrator") And Not StringInStr($array[$i][3], "SYSTEM") And _ Not StringInStr($array[$i][3], "Local Service") And Not StringInStr($array[$i][3], "Network Service") And _ $array[$i][3] <> "" Then MsgBox(0,"First username logged on",$array[$i][3]) EndIf Next Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 8, 2008 Share Posted July 8, 2008 It would also be possible to build another script that runs the "real" script and then uses CoProc.au3 or something similar to send the @Username to the "real" one. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
orion156 Posted July 29, 2008 Author Share Posted July 29, 2008 Airwolf: In my case the #requireadmin username and loginname could be different from time to time AdmiralAlkex: Is get an error when i use CoProc.au3. For instance when i run "Example_Golbals.au3" i get this message: CoProc_Send_Username_to_Real_script\CoProc.au3(49,47) : ERROR: Opt() called with illegal argument 1: "RunErrorsFatal" $iOldRunErrorsFatal = Opt("RunErrorsFatal", 0) Do you or anybody know what's wrong? Link to comment Share on other sites More sharing options...
archgriffin Posted July 29, 2008 Share Posted July 29, 2008 I have to assume I am wrong on this and I do not have a machine to test this on, but couldn't you grab @Username and set it in a variable before you declare the #requireadmin keyword? "Human kind cannot gain anything without first giving something in return, to obtain; something of equal value must be lost."The Help File is truly your friend. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 29, 2008 Share Posted July 29, 2008 Airwolf: In my case the #requireadmin username and loginname could be different from time to timeAdmiralAlkex: Is get an error when i use CoProc.au3. For instance when i run "Example_Golbals.au3" i get this message:CoProc_Send_Username_to_Real_script\CoProc.au3(49,47) : ERROR: Opt() called with illegal argument 1: "RunErrorsFatal" $iOldRunErrorsFatal = Opt("RunErrorsFatal", 0)Do you or anybody know what's wrong?CoProc.au3 was written for an earlier version of AutoIt. The latest version don't have "RunErrorsFatal" so comment/remove that line.If the CoProc stuff is bothering you, you may want to read about "Command Line Parameters" in the helpfile and build one script that launches the other with @UserName as a command line parameter.I have to assume I am wrong on this and I do not have a machine to test this on, but couldn't you grab @Username and set it in a variable before you declare the #requireadmin keyword?Jos explained this in a good way a couple of days ago.#RequireAdmin is a directive not a function. Thus it is set at program start time.Jos .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
orion156 Posted August 6, 2008 Author Share Posted August 6, 2008 CoProc.au3 was written for an earlier version of AutoIt. The latest version don't have "RunErrorsFatal" so comment/remove that line. If the CoProc stuff is bothering you, you may want to read about "Command Line Parameters" in the helpfile and build one script that launches the other with @UserName as a command line parameter. Jos explained this in a good way a couple of days ago. Thanx I used the command: Run( "script2.exe " & @UserName ) in script1.au3/.exe and the command $MyUsername = $CmdLine[1] in script2.au3/.exe Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now