Brasco Posted July 31, 2017 Share Posted July 31, 2017 Going a little crazy here and could use a couple other suggestions. At the end of the day, I'm trying to run a reporting program, generate a report, save it and move it. However, sometimes the database it is reporting off of is locked which can be mitigated by running the reporting program with administrative rights. The issue is, using RunAs, if I use 0, 1, or 4, it basically skips all my Control/ControlSend commands and nothing happens. When I use 2, it in fact sends the commands, but when it goes to generate the report, it fails with a locked database, making it seem like the program wasn't in fact opened with administrative rights (I confirmed by opening manually as an admin, the report is generated successfully so I know it's possible). Any other thoughts on what I can use? I've also tried RunAsWait and that didn't heed any more success than RunAs. Thanks a ton. $RUN_LOGON_NOPROFILE (0) - Interactive logon with no profile. $RUN_LOGON_PROFILE (1) - Interactive logon with profile. $RUN_LOGON_NETWORK (2) - Network credentials only. $RUN_LOGON_INHERIT (4) - Inherit the calling process's environment instead of the user's environment. FileCopy("C:\Program Files (x86)\EnvisionWare\lptone\lptjqe\jqe.mdb", @DesktopDir, 1) ;~ In case the LPT:One complains it doesnt know where the database file is, copy to desktop RunAs ( "username", "domain", "password", 0, "C:\Program Files (x86)\EnvisionWare\lptone\lptreport\lptreport.exe") If WinExists ("Please select the JQE database file.") Then ;~ Sometimes the program doesnt know where the database is. If this is true, show it. Otherwise continue on Send(@DesktopDir & "\jqe.mdb") Send("{ENTER}") EndIF #include <Date.au3> #include <Array.au3> Global $name=@ComputerName Global $month=@MON Global $day=@MDAY Global $year=@YEAR $aArray = _Date_GetFirst_LastOfPreviousMonth(_NowCalcDate()) ;~ _ArrayDisplay($aArray) WinWaitActive ("EnvisionWare® LPT:One™ V4 Quick Reporter") ControlSend("EnvisionWare® LPT:One™ V4 Quick Reporter", "", "[CLASS:QWidget; INSTANCE:18]", $aArray[0]);~ Send numeric last month Send("/") ControlSend("EnvisionWare® LPT:One™ V4 Quick Reporter", "", "[CLASS:QWidget; INSTANCE:18]", $aArray[1]);~ Send first day of last month (1) Send("/") ControlSend("EnvisionWare® LPT:One™ V4 Quick Reporter", "", "[CLASS:QWidget; INSTANCE:18]", $aArray[2]);~ Send year Send("{TAB}") ControlSend("EnvisionWare® LPT:One™ V4 Quick Reporter", "", "[CLASS:QWidget; INSTANCE:14]", $aArray[3]);~ Send numeric last month Send("/") ControlSend("EnvisionWare® LPT:One™ V4 Quick Reporter", "", "[CLASS:QWidget; INSTANCE:14]", $aArray[4]);~ Send last day of last month Send("/") ControlSend("EnvisionWare® LPT:One™ V4 Quick Reporter", "", "[CLASS:QWidget; INSTANCE:14]", $aArray[5]);~ Send year Send("{TAB}") Send("{ENTER}") Sleep(1000) Send("{TAB}") Sleep(1000) Send("{TAB}") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("C:\Users\envisionware\Desktop\"&$name&"Monthly_Print_Report-"&$month&"-"&$day&"-"&$year&".html");~ Name the report with PC name and current date Sleep(1000) Send("{TAB}") Sleep(1000) Send("{TAB}") Send("{TAB}") Send("{ENTER}") Send("{TAB}") Send("{TAB}") Send("{ENTER}") FileDelete (@DesktopDir & "\jqe.mdb");~ Delete database file Sleep(1000) FileMove (@DesktopDir & "\*.htm", "\\xx.xx.xx.xx\share\Monthly Usage Reports",$FC_OVERWRITE);~ Move report file to the reporting folder if .htm Func _Date_GetFirst_LastOfPreviousMonth($iThisMonth) Local $sLastMonth = _DateAdd("M", -1, $iThisMonth) Local $iDays = _DateDaysInMonth(StringLeft($sLastMonth, 4), StringMid($sLastMonth, 6, 2)) Local $aRetArray = [StringMid($sLastMonth, 6, 2), "01", StringLeft($sLastMonth, 4), _ StringMid($sLastMonth, 6, 2), $iDays, StringLeft($sLastMonth, 4)] Return $aRetArray EndFunc ;==>_Date_GetFirst_LastOfPreviousMonth Link to comment Share on other sites More sharing options...
spudw2k Posted August 1, 2017 Share Posted August 1, 2017 I suspect you can't interact with the process if it is elevated but your script is not. Have you tried adding #RequireAdmin to the top of the script to force the script to be executed with Admin rights? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Brasco Posted August 1, 2017 Author Share Posted August 1, 2017 Thanks @spudw2k, I just tried to add #RequireAdmin to the top of the script and it results in the access control box popping up and prompting for credentials, I'm assuming because the logged in user is not an adminstrator. 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