gcue Posted July 27, 2012 Share Posted July 27, 2012 (edited) hello. In Windows 7 - the script below works fine without #RequireAdmin but doesn't work when i add it. The ObjGet fails and I get the captured error. Unfortunately, I need #RequireAdmin for subsequent functions. Also, this is while logged in with an account that has local admin rights. #RequireAdmin $oRemedy = ObjGet("", "Remedy.User.1") If @error Then MsgBox(0, "Remedy Tracks", "Please login to Remedy first.") EndIf $ItemText = "GY0099000" $oRemedyForm = $oRemedy.LoadForm(0, "REMEDYSERVER", "Access Request Form", $ItemText, 4, True) In Windows XP, script works fine with or without #RequireAdmin Anyone else come across something similar? Not sure how to get around it. Edited July 27, 2012 by gcue Link to comment Share on other sites More sharing options...
BrewManNH Posted July 27, 2012 Share Posted July 27, 2012 I tested this with the example for ObjGet in the help file using Excel. If you run the script as admin, it will give me an error that it can't get the object of the open excel spreadsheet. If I open Excel as an administrator, and run the script using #RequireAdmin I can get it. It appears that both the script and the program you're trying to get the object of both have to be running using Run As Administrator (#RequireAdmin) for them to work together. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
gcue Posted July 27, 2012 Author Share Posted July 27, 2012 nice find works for me as well! is there a way to check to see if a program is running as administrator? i can probably build that in as part of the check - definitely not an obvious cause. Link to comment Share on other sites More sharing options...
water Posted July 27, 2012 Share Posted July 27, 2012 Check out function IsAdmin: Checks if the current user has full administrator privileges. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Mechaflash Posted July 27, 2012 Share Posted July 27, 2012 (edited) Check out function IsAdmin: Checks if the current user has full administrator privileges.A downfall to that is if a user isn't admin, and they open the application they're attempting to get the object from via RunAs admin. Edited July 27, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
gcue Posted July 27, 2012 Author Share Posted July 27, 2012 thanks for all the help/suggestions.. im just going to specify in the error message Please login to remedy first. If you are logged in, please run remedy as administrator. thanks again! Link to comment Share on other sites More sharing options...
Mechaflash Posted July 27, 2012 Share Posted July 27, 2012 I don't have time to look into right now... but logically... 1) Find the process i.d. 2) Find the user running the process (if a RunAs is used on the process, it will show up as that RunAs user) 3) Pass the user attached to the process into your ObjGet(), replacing .user. with the value. I think that will retrieve the object correctly? Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
water Posted July 27, 2012 Share Posted July 27, 2012 Maybe #RequireAdmin breaks your script because it starts a My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
gcue Posted July 27, 2012 Author Share Posted July 27, 2012 I don't have time to look into right now... but logically... 1) Find the process i.d. 2) Find the user running the process (if a RunAs is used on the process, it will show up as that RunAs user) 3) Pass the user attached to the process into your ObjGet(), replacing .user. with the value. I think that will retrieve the object correctly? interesting thought this is what you mean right? $oRemedy = ObjGet("", "Remedy." & @username & ".1") we only run one user at a time so user will be current user (@username) didn't work =/ Link to comment Share on other sites More sharing options...
gcue Posted July 27, 2012 Author Share Posted July 27, 2012 Maybe #RequireAdmin breaks your script because it starts a didn't know that - thanks for the info Link to comment Share on other sites More sharing options...
Mechaflash Posted July 27, 2012 Share Posted July 27, 2012 interesting thought this is what you mean right? $oRemedy = ObjGet("", "Remedy." & @username & ".1") we only run one user at a time so user will be current user (@username) didn't work =/ I meant getting the info of what user is attached to the process. If open Excel and you use the Administrator account to perform the RunAs with, the Process will be owned by Administrator and not what your current user is. Couldn't see any of our native _WinAPI_ functions that cover this... but I did find this article that has the Win32 API method of getting this info: http://www.codeproject.com/Articles/14828/How-To-Get-Process-Owner-ID-and-Current-User-SID Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
BrewManNH Posted July 27, 2012 Share Posted July 27, 2012 _WinAPI_GetProcessUser from might be useful to get the user running a process. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
gcue Posted July 27, 2012 Author Share Posted July 27, 2012 i got the user id manually (via task manager) to test to see if it would work didn't. creative idea though =) 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