Jump to content

Recommended Posts

Posted (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 by gcue
Posted

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 Gude
How to ask questions the smart way!

  Reveal hidden contents

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

Posted

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.

Posted

Check out function IsAdmin: Checks if the current user has full administrator privileges.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

  On 7/27/2012 at 2:22 PM, 'water said:

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 by mechaflash213
  Reveal hidden contents

 

Posted

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!

Posted

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?

  Reveal hidden contents

 

Posted

Maybe #RequireAdmin breaks your script because it starts a

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

  On 7/27/2012 at 4:19 PM, 'mechaflash213 said:

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 =/

Posted

  On 7/27/2012 at 4:32 PM, 'water said:

Maybe #RequireAdmin breaks your script because it starts a

didn't know that - thanks for the info :idiot:

Posted

  On 7/27/2012 at 6:52 PM, 'gcue said:

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

  Reveal hidden contents

 

Posted

_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 Gude
How to ask questions the smart way!

  Reveal hidden contents

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

Posted

i got the user id manually (via task manager) to test to see if it would work

didn't.

creative idea though =)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...