aspcomp Posted May 9, 2007 Share Posted May 9, 2007 hello. i've created a script using autoit and converted into an .exe file. i have a batch file associated with user accounts in active directory and this batch (that has this script) works fine when users logon to their xp machines... but since we're using terminal server environment, i don't want this script to run when user logons to term.server session but it does. basically this script runs both on xp pro and when user logons to term.server session (which i don't want). any ideas? these are 2 ideas i have but don't know how to accomplish this or not sure if they may work: 1. in autoit coding, put something like if user logging into xp pro then run this 'one line of code', if user logging into terminal server then don't run this line of code. 2. how to disable .exe file running when user logons to terminal server. (don't think this idea is associated with autoit). cheers. Link to comment Share on other sites More sharing options...
evilertoaster Posted May 9, 2007 Share Posted May 9, 2007 for option 2 try and google search about logon scripts from terminal servers...here's one results i found that shows what to do - http://www.tutorials-xe.com/TERMINAL/disable-user-33046/...there's probably also a way to find out if your running a terminal session in autoit but i don't know of the top of my head... Link to comment Share on other sites More sharing options...
aspcomp Posted May 9, 2007 Author Share Posted May 9, 2007 sorry i made a complete mistake in my posting: the batch script (testing.bat) has coding PLUS one line that points to a file i created in autoit (e.g. test.exe) and obviously executes this test.exe file when user logs in. i want this batch script (testing.bat) to run in both xp pro and user's terminal server session, however i just don't want that 'one line of coding' that points to 'test.exe' in the batch script to run in the terminal server session. does this make sense? so maybe in autoit there might be coding saying if user logging in xp then execute this test.exe, if user is logging in term.session then don't run this line. cheers. Link to comment Share on other sites More sharing options...
evilertoaster Posted May 9, 2007 Share Posted May 9, 2007 using CompInfo.au3 you can get the sessionID. If the sessionID is not zero, then you are running a terminal session and can code accordingly. Link to comment Share on other sites More sharing options...
aspcomp Posted May 9, 2007 Author Share Posted May 9, 2007 hi there. cheers. you've been very helpful. i'm very new to this autoit program and i have seen the file compinfo.au3 it's very long. i have to ask--what do i do? how do i code my session line? thank you so much. Link to comment Share on other sites More sharing options...
evilertoaster Posted May 9, 2007 Share Posted May 9, 2007 somthing like this- #include <compinfo.au3> dim $Array _ComputerGetProcesses($Array) Global $val="Defualt" for $a=0 to $Array[0][0] if $Array[$a][26]=@AutoItPID Then $val=$Array[$a][33] ExitLoop EndIf Next if String($val)="Defualt" Then MsgBox(0,"Error","AutoIt cant find its own PID :(") Exit EndIf if $val=0 Then ;runs code if NOT terminal session Else ;runs code if IS terminal session EndIf Link to comment Share on other sites More sharing options...
aspcomp Posted May 9, 2007 Author Share Posted May 9, 2007 brilliant! cheers! do i actually have to include the compinfo.au3 file then or was that optional? cuz if i did include it then everything in compinfo.au3 will run won't it? somthing like this- #include <compinfo.au3> dim $Array _ComputerGetProcesses($Array) Global $val="Defualt" for $a=0 to $Array[0][0] if $Array[$a][26]=@AutoItPID Then $val=$Array[$a][33] ExitLoop EndIf Next if String($val)="Defualt" Then MsgBox(0,"Error","AutoIt cant find its own PID :(") Exit EndIf if $val=0 Then ;runs code if NOT terminal session Else ;runs code if IS terminal session EndIf Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 9, 2007 Share Posted May 9, 2007 brilliant! cheers! do i actually have to include the compinfo.au3 file then or was that optional? cuz if i did include it then everything in compinfo.au3 will run won't it? Include files don't work that way. The include a bunch of function definitions. If you don't call the unused functions, they don't do anything. You can open compinfo.au3 and just pull out the one function you are interested in. For example this is _ComputerGetProcesses(): CODEexpandcollapse popup;=============================================================================== ; Description: Returns the Process information in an array. ; Parameter(s): $aProcessInfo - By Reference - Process Information array. ; Requirement(s): None ; Return Value(s): On Success - Returns array of Process Information. ; $aProcessInfo[0][0] = Number of Processes ; $aProcessInfo[$i][0] = Name ($i starts at 1) ; $aProcessInfo[$i][1] = Command Line ; $aProcessInfo[$i][2] = Creation Class Name ; $aProcessInfo[$i][3] = Creation Date ; $aProcessInfo[$i][4] = Description ; $aProcessInfo[$i][5] = CS Creation Class Name ; $aProcessInfo[$i][6] = CS Name ; $aProcessInfo[$i][7] = Executable Path ; $aProcessInfo[$i][8] = Execution State ; $aProcessInfo[$i][9] = Handle ; $aProcessInfo[$i][10] = Handle Count ; $aProcessInfo[$i][11] = Kernel Mode Time ; $aProcessInfo[$i][12] = Maximum Working Set Size ; $aProcessInfo[$i][13] = Minimum Working Set Size ; $aProcessInfo[$i][14] = OS Creation Class Name ; $aProcessInfo[$i][15] = OS Name ; $aProcessInfo[$i][16] = Other Operation Count ; $aProcessInfo[$i][17] = Other Transfer Count ; $aProcessInfo[$i][18] = Page Faults ; $aProcessInfo[$i][19] = Page File Usage ; $aProcessInfo[$i][20] = Parent Process ID ; $aProcessInfo[$i][21] = Peak Page File Usage ; $aProcessInfo[$i][22] = Peak Virtual Size ; $aProcessInfo[$i][23] = Peak Working Set Size ; $aProcessInfo[$i][24] = Priority ; $aProcessInfo[$i][25] = Private Page Count ; $aProcessInfo[$i][26] = Process ID ; $aProcessInfo[$i][27] = Quota Non Paged Pool Usage ; $aProcessInfo[$i][28] = Quota Paged Pool Usage ; $aProcessInfo[$i][29] = Quota Peak Non Paged Pool Usage ; $aProcessInfo[$i][30] = Quota Peak Paged Pool Usage ; $aProcessInfo[$i][31] = Read Operation Count ; $aProcessInfo[$i][32] = Read Transfer Count ; $aProcessInfo[$i][33] = Session ID ; $aProcessInfo[$i][34] = Status ; $aProcessInfo[$i][35] = Thread Count ; $aProcessInfo[$i][36] = User Mode Time ; $aProcessInfo[$i][37] = Virtual Size ; $aProcessInfo[$i][38] = Windows Version ; $aProcessInfo[$i][39] = Working Set Size ; $aProcessInfo[$i][40] = Write Operation Count ; $aProcessInfo[$i][41] = Write Transfer Count ; On Failure - @error = 1 and Returns 0 ; @extended = 1 - Array contains no information ; 2 - $colItems isnt an object ; Author(s): Jarvis Stubblefield (support "at" vortexrevolutions "dot" com) ; Note(s): ;=============================================================================== Func _ComputerGetProcesses(ByRef $aProcessInfo) Local $colItems, $objWMIService, $objItem Dim $aProcessInfo[1][42], $i = 1 $objWMIService = ObjGet("winmgmts:\\" & $cI_Compname & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems ReDim $aProcessInfo[UBound($aProcessInfo) + 1][42] $aProcessInfo[$i][0] = $objItem.Name $aProcessInfo[$i][1] = $objItem.CommandLine $aProcessInfo[$i][2] = $objItem.CreationClassName $aProcessInfo[$i][3] = __StringToDate($objItem.CreationDate) $aProcessInfo[$i][4] = $objItem.Description $aProcessInfo[$i][5] = $objItem.CSCreationClassName $aProcessInfo[$i][6] = $objItem.CSName $aProcessInfo[$i][7] = $objItem.ExecutablePath $aProcessInfo[$i][8] = $objItem.ExecutionState $aProcessInfo[$i][9] = $objItem.Handle $aProcessInfo[$i][10] = $objItem.HandleCount $aProcessInfo[$i][11] = $objItem.KernelModeTime $aProcessInfo[$i][12] = $objItem.MaximumWorkingSetSize $aProcessInfo[$i][13] = $objItem.MinimumWorkingSetSize $aProcessInfo[$i][14] = $objItem.OSCreationClassName $aProcessInfo[$i][15] = $objItem.OSName $aProcessInfo[$i][16] = $objItem.OtherOperationCount $aProcessInfo[$i][17] = $objItem.OtherTransferCount $aProcessInfo[$i][18] = $objItem.PageFaults $aProcessInfo[$i][19] = $objItem.PageFileUsage $aProcessInfo[$i][20] = $objItem.ParentProcessId $aProcessInfo[$i][21] = $objItem.PeakPageFileUsage $aProcessInfo[$i][22] = $objItem.PeakVirtualSize $aProcessInfo[$i][23] = $objItem.PeakWorkingSetSize $aProcessInfo[$i][24] = $objItem.Priority $aProcessInfo[$i][25] = $objItem.PrivatePageCount $aProcessInfo[$i][26] = $objItem.ProcessId $aProcessInfo[$i][27] = $objItem.QuotaNonPagedPoolUsage $aProcessInfo[$i][28] = $objItem.QuotaPagedPoolUsage $aProcessInfo[$i][29] = $objItem.QuotaPeakNonPagedPoolUsage $aProcessInfo[$i][30] = $objItem.QuotaPeakPagedPoolUsage $aProcessInfo[$i][31] = $objItem.ReadOperationCount $aProcessInfo[$i][32] = $objItem.ReadTransferCount $aProcessInfo[$i][33] = $objItem.SessionId $aProcessInfo[$i][34] = $objItem.Status $aProcessInfo[$i][35] = $objItem.ThreadCount $aProcessInfo[$i][36] = $objItem.UserModeTime $aProcessInfo[$i][37] = $objItem.VirtualSize $aProcessInfo[$i][38] = $objItem.WindowsVersion $aProcessInfo[$i][39] = $objItem.WorkingSetSize $aProcessInfo[$i][40] = $objItem.WriteOperationCount $aProcessInfo[$i][41] = $objItem.WriteTransferCount $i += 1 Next $aProcessInfo[0][0] = UBound($aProcessInfo) - 1 If $aProcessInfo[0][0] < 1 Then SetError(1, 1, 0) EndIf Else SetError(1, 2, 0) EndIf EndFunc ;_ComputerGetProcessesPersonally, I'd rather just have the #include line. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 9, 2007 Share Posted May 9, 2007 Just for my own education, what does an AutoIt script running in a terminal services session return for the @OS* macros? MsgBox(64, "OS", "@OSBuild: " & @OSBuild & @CRLF & _ "@OSLang: " & @OSLang & @CRLF & _ "@OSServicePack: " & @OSServicePack & @CRLF & _ "@OSType: " & @OSTYPE & @CRLF & _ "@OSVersion: " & @OSVersion) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
aspcomp Posted May 9, 2007 Author Share Posted May 9, 2007 thank you; i understand now. i'll be using the #include file. i tested it locally and it works fine. i'm going to test it on my ts--i hope my terminal server won't crash on me knock on wood mate! cheers. Link to comment Share on other sites More sharing options...
evilertoaster Posted May 9, 2007 Share Posted May 9, 2007 A mutilated version that doesn't need the include is expandcollapse popupdim $Array _ComputerGetProcesses($Array) Global $val="Defualt" for $a=0 to $Array[0][0] if $Array[$a][1]=@AutoItPID Then $val=$Array[$a][2] ExitLoop EndIf Next if String($val)="Defualt" Then MsgBox(0,"Error","AutoIt cant find its own PID ") Exit EndIf if $val=0 Then ;runs code if NOT terminal session Else ;runs code if IS terminal session EndIf Func _ComputerGetProcesses(ByRef $aProcessInfo) Local $colItems, $objWMIService, $objItem Dim $aProcessInfo[1][42], $i = 1 $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems ReDim $aProcessInfo[UBound($aProcessInfo) + 1][3] $aProcessInfo[$i][1] = $objItem.ProcessId $aProcessInfo[$i][2] = $objItem.SessionId $i += 1 Next $aProcessInfo[0][0] = UBound($aProcessInfo) - 1 If $aProcessInfo[0][0] < 1 Then SetError(1, 1, 0) EndIf Else SetError(1, 2, 0) EndIf EndFunc But that's kinda troublesome i guess... Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 9, 2007 Share Posted May 9, 2007 thank you; i understand now.i'll be using the #include file. i tested it locally and it works fine.i'm going to test it on my ts--i hope my terminal server won't crash on me knock on wood mate!cheers.If you've got a terminal server to play with, could you test the one-line script in post #9 and tell me what you get?Thanx. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
aspcomp Posted May 9, 2007 Author Share Posted May 9, 2007 i get osservicepack=OSSP1ostype: WIN32_NTosversion: WIN_2003i think it is recognising the values of the term.server the script works well thank you all for you assistance.If you've got a terminal server to play with, could you test the one-line script in post #9 and tell me what you get?Thanx. Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 10, 2007 Share Posted May 10, 2007 i get osservicepack=OSSP1ostype: WIN32_NTosversion: WIN_2003i think it is recognising the values of the term.server the script works well thank you all for you assistance.Thanks; and you're welcome. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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