Jump to content



Photo

@LogonType


  • This topic is locked This topic is locked
4 replies to this topic

#1 Gigglestick

Gigglestick

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 501 posts

Posted 05 September 2007 - 08:57 PM

I am writing an AutoIt program that will present a GUI and walk the user through the script when run by a user who's logged on interactively (at the console or via Terminal Services/RDP), or just perform some preconfigured work and quit if run non-interactively (via Scheduled Tasks). The only way I've found to detect this logon type is using something like the following code snippet (which doesn't seem to be 100% reliable). For instance, you could double-click the executable to create an INI file, then create a Scheduled Task to run the executable using that INI file to run siliently. I know I could just run silently if an INI is specified on the command-line, and interactively if not, but I think this request may have some other value as well.

$strComputer = "." $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colSessions = $objWMIService.ExecQuery("Select * from Win32_LogonSession Where LogonType=2 or LogonType=10") For $objSession in $colSessions     $colList = $objWMIService.ExecQuery("Associators of {Win32_LogonSession.LogonId=" & $objSession.LogonId & "} Where AssocClass=Win32_LoggedOnUser Role=Dependent")     For $objItem in $colList         If @UserName = $objItem.Name Then         ; do something interactively         Else         ; do non-interactive tasks         EndIf     Next Next

I can't help but think this might not be all that hard to implement in Autoit3 as a macro, such as a @LogonType that matches the Win32_LogonSession.LogonType values, or even just a simpler, boolean @LogonInteractive or something. I'm sure it would be much quicker than WMI also.

If there's already a feature like this in AutoIt3, please let me know.

Thoughts?
My UDFs: ExitCodes





#2 mbkowns

mbkowns

    Wayfarer

  • Active Members
  • Pip
  • 77 posts

Posted 30 January 2008 - 06:47 AM

I am writing an AutoIt program that will present a GUI and walk the user through the script when run by a user who's logged on interactively (at the console or via Terminal Services/RDP), or just perform some preconfigured work and quit if run non-interactively (via Scheduled Tasks). The only way I've found to detect this logon type is using something like the following code snippet (which doesn't seem to be 100% reliable). For instance, you could double-click the executable to create an INI file, then create a Scheduled Task to run the executable using that INI file to run siliently. I know I could just run silently if an INI is specified on the command-line, and interactively if not, but I think this request may have some other value as well.

$strComputer = "." $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colSessions = $objWMIService.ExecQuery("Select * from Win32_LogonSession Where LogonType=2 or LogonType=10") For $objSession in $colSessions     $colList = $objWMIService.ExecQuery("Associators of {Win32_LogonSession.LogonId=" & $objSession.LogonId & "} Where AssocClass=Win32_LoggedOnUser Role=Dependent")     For $objItem in $colList         If @UserName = $objItem.Name Then     ; do something interactively         Else     ; do non-interactive tasks         EndIf     Next Next

I can't help but think this might not be all that hard to implement in Autoit3 as a macro, such as a @LogonType that matches the Win32_LogonSession.LogonType values, or even just a simpler, boolean @LogonInteractive or something. I'm sure it would be much quicker than WMI also.

If there's already a feature like this in AutoIt3, please let me know.

Thoughts?


I am wondering about this also.

Basically just a way to detect when a RDP session is disconnected on the machine so I can run

%windir%\System32\tscon.exe 0 /dest:console

and have it log me back into my current session. If I get this to work I am going to make this a windows service.

#3 ezik

ezik

    Seeker

  • Active Members
  • 7 posts

Posted 01 February 2008 - 06:52 PM

Hi, i cant make my own topic so i post here, iam looking for script which can click all the time to "F4" + "4" very fast, about 0.1s delay, Start = mause 6 button, Stop = mause 7 button. Iam newbie in AutoIt so i cant do it myself, could help me anyone please ?

Edited by ezik, 01 February 2008 - 06:54 PM.


#4 Jos

Jos

    oh joy ...

  • Developers
  • 21,052 posts

Posted 01 February 2008 - 06:56 PM

Hi, i cant make my own topic so i post here, iam looking for script which can click all the time to "F4" + "4" very fast, about 0.1s delay, Start = mause 6 button, Stop = mause 7 button. Iam newbie in AutoIt so i cant do it myself, could help me anyone please ?

Support requests need to go into the support forum and I am sure you can create topic there.

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#5 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 01 February 2008 - 07:16 PM

Support requests need to go into the support forum and I am sure you can create topic there.

I have a better suggestion for the user, give up trying to use AutoIt and take up something like knitting. I fail to see how somebody who can't even figure out how to post in the right place can actually be productive with a scripting language.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users