Advert
AmbientMike
Active Members-
Posts
34 -
Joined
-
Last visited
AmbientMike's Achievements
Seeker (1/7)
0
Reputation
-
Many thanks, SlackerAI. That very much pointed me in the right direction. Here is my semi-final code... ; Now sort the array by Application Name _ArraySort ( $ArraySoftwareUsage, 0, 0, 0, 1) $ArraySize2 = UBound($ArraySoftwareUsage) $RunningTotalRuns = 0 $RunningTotalAverageTime = 0 Global $ArraySoftwareUsage2[1][4] For $i = 0 to ($ArraySize2 - 1) ; Get current Application Name $ReadApplicationName = $ArraySoftwareUsage[$i][1] ; Read Application Name from previous line (If line No. > 0) If ($i > 0) Then $PreviousAppName = $ArraySoftwareUsage[($i -1)][1] Else $PreviousAppName = $ReadApplicationName EndIf $RunningTotalRuns = $RunningTotalRuns + $ArraySoftwareUsage[$i][2] $RunningTotalAverageTime = $RunningTotalAverageTime + $ArraySoftwareUsage[$i][3] ; When Application name changes write values to new array If $ReadApplicationName <> $PreviousAppName Then $ArrayNumber2 = $ArrayNumber2 + 1 ReDim $ArraySoftwareUsage2[($ArrayNumber2 + 1)][4] ; Total up the App usage and write to new array $ArraySoftwareUsage2[$ArrayNumber2][0] = $Image $ArraySoftwareUsage2[$ArrayNumber2][1] = $ReadApplicationName $ArraySoftwareUsage2[$ArrayNumber2][2] = $RunningTotalRuns $ArraySoftwareUsage2[$ArrayNumber2][3] = $RunningTotalAverageTime ; Reset counting variables $RunningTotalRuns = 0 $RunningTotalAverageTime = 0 EndIf Next _ArrayDisplay($ArraySoftwareUsage2) Exit
-
Hi, I have a problem I'm trying to overcome and I've hit a brick wall with a certain aspect of it. I have an array where one column contains many duplicates and then two other collums that I need summing IF column x is identical. An example of this array would be... [COMPUTERNAME1][APPLICATION1][2][4] [COMPUTERNAME1][APPLICATION2][3][3] [COMPUTERNAME2][APPLICATION1][7][1] [COMPUTERNAME2][APPLICATION2][2][5] So as an output I want to be able to basically merge the duplicate data (from column 2) whilst summing columns 3 and 4 (column 1 can be ignored)... [APPLICATION1][9][5] [APPLICATION2][5][8] I don't know what the contents of column 2 are going to be. I don't have any code to paste as an example as I haven't found any functions that will even get me started on the right path without losing data form columns 3 & 4. Any pointers would be very welcome at this point in time. Cheers...
-
List applications open on the TaskBar?
AmbientMike replied to AmbientMike's topic in AutoIt General Help and Support
Thanks, but I suspect that WinList() will also list the MSHTA.exe window I am looking for early as presumably is uses the same API as the WinExists command and the process opens some 10 seconds or so before the windows is visible so that is no use to me hence why I am looking specifically for when an icon is displayed on the taskbar. -
List applications open on the TaskBar?
AmbientMike posted a topic in AutoIt General Help and Support
Hi, I am trying to find a way to detect if two applications are running (and visible in the GUI). One sits in the system tray (which I've got sorted) but another launches (so is easily visible as a running process) but seems to delay until showing in the GUI but the "WinExists" command seems to pick it up a few seconds before it's actually visible! The bit of script that detects the system tray app is modified from somewhere on these forums that finds the text labels from all of the tray icons... Func Get_Systray_IconText($sToolTipTitle) Local $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) Local $iSystray_ButtonNumber For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1 Local $sText = _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber) If StringInStr($sText, $sToolTipTitle) = 1 Then Return $sText EndIf Next Return SetError(1, 0, "") EndFunc So I was hoping that there was something nearly identical that detects icons in the Taskbar in a near-identical way as ProcessExists and WinExists commands seem to detect it too early and I really need to detect the time that the window is visible to the user which seems to be when it spawns it's taskbar icon. Any ideas? -
Now I didn't think that was working because with that on its own I get no visible window but if I use... GUISetState() GUISetState(@SW_DISABLE) Then it works. Thanks - easier than I had imagined! EDIT - That worked to some degree. For completeness I managed to force the GUI to be bottom-most by the addition of the following... #include <WINAPI.au3> _WinAPI_SetWindowPos ( $hGUI1, $HWND_BOTTOM, $POSX, $POSY, $GUIWidth, $GUIHeight, $SWP_NOACTIVATE )
-
OK - I've made a transparent GUI with some text that I want to use as a sort of desktop splash / info panel on the desktop - that's all working well. What I'd like is to be able to keep the GUI underneath all windows and stop the GUI ever getting focus as if it were just part of the desktop. I know there are utilities out there that do this sort of thing already but they don't meet my needs so I'm trying to script one. Anyone have any ideas on if this can be achieved the way I want or is there a smarter way of doing it without a transparent GUI and text labels?
-
I have provided my full scripts... I'll try to flesh it out a bit more. This is more of a way to leverage the power of PSExec rather than show the power of AutoIt. PSExec is stored in my C:Windows directory http://technet.microsoft.com/en-gb/sysinternals/bb897553.aspx This script is run as a scheduled task "At startup" as the "SYSTEM" user, "Run whether user is logged on or not" and "Run with highest privileges" and not "Hidden"... While 1 If FileExists ("C:\Temp\Reg") Then FileDelete ("C:\Temp\Reg") ShellExecute ( @WindowsDir & "\psexec.exe" , "-accepteula \\127.0.0.1 -d -e -i -s cmd /c start 'PUT YOUR 1ST COMMAND HERE'" ) EndIf If FileExists ("C:\Temp\UnReg") Then FileDelete ("C:\Temp\UnReg") ShellExecute ( @WindowsDir & "\psexec.exe" , "-accepteula \\127.0.0.1 -d -e -i -s cmd /c start 'PUT YOUR 2ND COMMAND HERE'" ) EndIf sleep(10) WEnd So this just sits looping in the background basically looking for one or either file to exist... C:TempReg or C:TempUnReg I chose that location as I know that's a world-writeable scratch area we use but feel free to use any other directory as long as everyone has at least modify rights to it. I have this script looking for two files as I need to only run two commands but you could have it look for any file and any number of items or look for one file but vary the contents and do a FileReadLine if desired. Then I give the users their own scripts (doesn't even need to be an AutoIt script - a simple batch file will suffice but in my case I use two AutoIt scripts, each with one line in them... filewrite("c:\temp\Reg", " ") filewrite("c:\temp\UnReg", " ") So the user simply creates a file in an area they have rights to and the script running as SYSTEM catches the existence of that file and runs a PSExec command as required. In my case it runs a couple of PowerShell scripts that only work as an admin. I hope that makes it a little more clear. In truth, in writing this I think I've just figured out a way to do this with only Scheduled Tasks and cutting out AutoIt but it's too late to start thinking about that now. Bear in mind that this DOES NOT run the command as the user (there is simply no way to run commands elevated to administrator by a standard user account as Windows cannot do it) instead it runs it as SYSTEM but visible to the user so anything that relies on modifying the user's profile files or registry then you will need to do a little more to check for the console user - but these commands can normally be run as the user anyway). I don't recall if powercfg is per user or per computer but I'd presume it's per computer as you can only run one power profile at any one time so this should work without any modification as far as I'm aware.
-
Well, in your script you're opening notepad - which all users can do. The commands that I need to run will only work correctly as admin - they will launch as a user but will fail to make amendments to the computer as required. Just putting #RequireAdmin at the top of a script and getting a non-admin user to run it will NOT grant them admin rights - it will just prompt for admin credentials which you're aware of. Also I think you have misunderstood - I don't run the PSEXEC command as the user - it is run as SYSTEM (so I probably don't need the "-s" switch in there really) but is watching for a file to be dropped in a certain location by a non-admin user to run the command. In the scheduled task that starts the main loop as SYSTEM it's set to run with highest privileges. All the non-admin accounts are actually doing is creating a file in a location that the SYSTEM script is looking for and then running commands as required but visible to the logged in user.
-
Sorry for dredging up my old topic but as I'm re-building my Windows 8 image from scratch using a Windows 8.1 Enterprise base I thought I'd let you know that I've managed to simplify things a bit this year managing to let users run a couple of commands as admin (well SYSTEM actually!). One thing I noticed over the last year is that Microsoft tend to use Scheduled Tasks more often than just putting a shortcut into the startup folder these days it seems. And last year for some reason I completely forgot about the great tool that is PSEXEC. PSExec.exe needs to be in the Windows dir for this one... So what I do is have an autoit script running as SYSTEM at PC startup via a scheduled task with "Run with highest privileges" enabled awaiting for two particular files to exist using the following little bit of script... While 1 If FileExists ("C:\Temp\Reg") Then FileDelete ("C:\Temp\Reg") ShellExecute ( "C:\Windows\psexec.exe" , "-accepteula \\127.0.0.1 -d -e -i -s cmd /c reg add 'HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' /v ExecutionPolicy /t REG_SZ /d RemoteSigned /f" ) ShellExecute ( "C:\Windows\psexec.exe" , "-accepteula \\127.0.0.1 -d -e -i -s cmd /c start /min powershell.exe -windowstyle hidden C:\Windows\VS2012Configs\RegAccount.ps1" ) EndIf If FileExists ("C:\Temp\UnReg") Then FileDelete ("C:\Temp\UnReg") ShellExecute ( "C:\Windows\psexec.exe" , "-accepteula \\127.0.0.1 -d -e -i -s cmd /c reg add 'HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' /v ExecutionPolicy /t REG_SZ /d RemoteSigned /f" ) ShellExecute ( "C:\Windows\psexec.exe" , "-accepteula \\127.0.0.1 -d -e -i -s cmd /c start /min powershell.exe -windowstyle hidden C:\Windows\VS2012Configs\UnReg.ps1" ) EndIf sleep(10) WEnd Then I have two simple, one line scripts that can be run by someone with just user rights (everyone has modify rights to C:Temp)... filewrite("c:\temp\Reg", " ") filewrite("c:\temp\UnReg", " ") Then for all intents and purposes the user has admin rights to run those two commands and those two only because PSExec is being called from System with the -d -e -i -s switches -d Don't wait for process to finish -e Don't load user profile -i Interacts with desktop -s Run as System account No UAC, just "happy" users being able to do what they need to do as admin (and nothing more).
-
Cheers - I will take a look and see if that works for me in WIndows 8. I suspect that for my purposes running these 2 small objects as SYSTEM may actually be safer than using encrypted admin passwords where the hash can be found through decompilation. Our admin password is pretty insane so would take a looooong time to decypher it though.
-
So ignoring all the encrypted password stuff all it is really doing is RunAs() and #RequireAdmin but the key is to set the reg key to 0 of the following key... HKLMSoftwareMicrosoftWindowsCurrentVersionPoliciesSystemEnableInstallerDetection And what is the status of the following reg key on your systems? 0 or 1? HKLMSoftwareMicrosoftWindowsCurrentVersionPoliciesSystemEnableLUA The Microsoft link you gave states that it is for package installation. Does this work for running batch files, scripts etc or just for installer packages?
-
Well as I've said - I've already got the PowerShell script that does the registering of accounts running as SYSTEM and interacting with the desktop with a modified script linked to somewhere above and also I've made an unregister script during the login process so that one student's account isn't misused by another student. It works pretty much seamlessly - I just don't want to have to rely on this moving forward - although at least we don't have any plans on rolling out Windows 8 to anywhere else but this one lab for a loooong time to come. I should also say that we don't currently have SCCM 2012 so we can't manage Windows 8 machines with that otherwise I suppose we could have created an SCCM advert that students could run to register an account and that could have run with highest privileges. EDIT - adding a developer account has an online check so I don't think just catching the registry and disk read / writes would cut it in order to bypass elevation.
-
We have SCCM and a WSUS server - in which case you'll ask my why the f*ck am I trying to resolve this task in this manner... Don't ask... I'll spell it out completely so nobody can misunderstand what I am doing and what I initially asked. Our Compute Science department have an upcoming module learning to code Windows Store & Phone 8 apps. For this you need Windows 8, Visual Studio 2012 and Windows Phone 8 SDK. Microsoft also state that you need admin rights. There are two pre-requisites here - our students CANNOT have admin rights as our ISP demands it. So disconnect the PC's from the network - easy!!! No! The PC's need network access in order to register a developer account on the PC and the user needs admin rights to perform this. You cannot code a Windows Store app in VS2012 unless you have a registered account (any Live account will do). We also have to have UAC enabled for the virtual environment for Windows Store apps to run in. Therefore - as I've stated (and already fixed) our students need to run application(s) as administrator without UAC or requests for admin credentials getting in the way to install and remove their developer accounts to the PC just so that we can enable a course to be taught where Microsoft really don't want to be helpful and allow a user to register the developer account for their login only but for the whole computer. Outside of that VS2012 seems to work perfectly happily as a standard user once an account has been registered with the PC.