AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Admin-rights for Registry

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Wed Mar 09, 2005 7:47 am    Post subject: Admin-rights for Registry Reply with quote

Hello Chris,

is it possible to enhance the Registry-Commands, that it is possible to specify a username and password?

Tekl
Back to top
View user's profile Send private message Visit poster's website
BoBo
Guest





PostPosted: Wed Mar 09, 2005 8:15 am    Post subject: Reply with quote

AHK's RunAs ???
Back to top
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Wed Mar 09, 2005 9:25 am    Post subject: Reply with quote

Yes, I know about RunAs, but I need registry-access even if the current user is no admin. Not all registry-entries are accessable as a normal user.

Tekl
Back to top
View user's profile Send private message Visit poster's website
BoBo
Guest





PostPosted: Wed Mar 09, 2005 9:48 am    Post subject: Reply with quote

@ Tekl
Quote:
Not all registry-entries are accessable as a normal user
Ich dachte das macht genau den Unterschied zum Admin aus ?

btw: checke bitte noch mein posting zum c't artikel. Grazie. Very Happy
Back to top
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Wed Mar 09, 2005 1:48 pm    Post subject: Reply with quote

Hi Bobo,

it's hard for foreigners to read answers in german.

I want to make changes in the registry and if the user is not admin the script should ask for admins password.

Tekl
Back to top
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Wed Mar 09, 2005 3:37 pm    Post subject: Reply with quote

Who is foreigner to whom? (Wir sind nur scheiß' Ausländer)
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Wed Mar 09, 2005 3:55 pm    Post subject: Re: Admin-rights for Registry Reply with quote

Tekl wrote:
is it possible to enhance the Registry-Commands, that it is possible to specify a username and password?
I suspect it is possible but I don't see a way to do it directly in the Windows API. The nearest function is RegConnectRegistry(), which accepts only the computer name, not a user/pass.

It might already be possible to do it indirectly by establishing a connection, such as mapping a network drive, from the computer to itself using the admin user/password. Once this is done, the registry commands might work, though you might have to specify the computer name to force a connection over the network interface as in this example:

RegWrite, REG_SZ,, \\%A_ComputerName%:HKLM, SOFTWARE\TestKey, MyValueName, Test Value

If it doesn't work, I'm at a dead end. Perhaps someone here knows how to access the registry directly using a user/pass.
Back to top
View user's profile Send private message Send e-mail
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Wed Mar 09, 2005 3:57 pm    Post subject: Reply with quote

foreigner, n 1: a person who comes from a foreign country; someone who does not owe allegiance to your country

To them, we're the foreigners. Unless you take the traditional American view that everyone else is a foreigner, even when you're in their country. Laughing Even though we're all "foreigners" ourselves, excluding those of Native American descent.
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Wed Mar 09, 2005 4:24 pm    Post subject: Reply with quote

In a .com (not .de) forum nobody should be foreigner. But we are off topic now…
Back to top
View user's profile Send private message
Nemroth



Joined: 07 Sep 2004
Posts: 262
Location: France

PostPosted: Wed Mar 09, 2005 5:54 pm    Post subject: Reply with quote

Yes we are off topic, but not off forum.
I think the question is not to know who is foreigner or not. But it's a good thing to be understood by everyone. So I think that the non english/american guys would be nice at least to translate (even concisely) what they write in their own language in english/american.
Ou alors, étant donné que le français est le langage diplomatique (ou a été, mais je crois que c'est toujours le cas officiellement), il est préférable que tout le monde s'exprime en français. Et voilà !
Or, as French is the diplomatic language (or was, but I think that it is always the case officialy), it is better if everybody expresses himself in French. Et voilà ! Laughing Laughing Laughing
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Wed Mar 09, 2005 6:18 pm    Post subject: Reply with quote

We should really move these to the general chat area, but, of course we have to use a language that everybody understands in the forum. Having been a scheiß' Ausländer for a while, I am a little sensitive to be called foreigner. It shows where the center of the universe is in some guys' heads (or just an unfortunate expression from a non-English speaker).
Back to top
View user's profile Send private message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Wed Mar 09, 2005 11:23 pm    Post subject: Reply with quote

Hi,

back to topic. Chris' suggestion does not work. Where should the user/password be asked for? There is no dialog asking. Is it possible to enclose them like for URLs?

name:password@www.domain.de

Well I tested that and it does not work.

tekl
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Thu Mar 10, 2005 12:25 am    Post subject: Reply with quote

I just realized there's a fairly simple way that should work: RunAs. By having a script launch some a second script under the credentials of an administrator, the second script's use of RegWrite should be unrestricted. However, in order for RunAs to work, I think you will have to launch the script with the full path to AutoHotkey as in this example:
Code:
RegRead, ahk_dir, HKEY_LOCAL_MACHINE, SOFTWARE\AutoHotkey, InstallDir
if ErrorLevel <> 0  ; Use a best guess location instead.
   ahk_dir = %ProgramFiles%\AutoHotkey
ahk_exe = %ahk_dir%\AutoHotkey.exe
IfNotExist %ahk_exe%
{
   MsgBox "%ahk_exe%" does not exist.
   return
}

InputBox, User, Username, Enter the username of an administrator:
if (ErrorLevel or not User)  ; User pressed cancel or left it blank.
   return
InputBox, Pass, Password, Enter that user's password (masked):, hide
if ErrorLevel  ; But allow a blank password, since that might be valid for the specified user.
   return
RunAs, %User%, %Password%
RunWait %ahk_exe% "MyRegWrite.ahk"
The above could be simplified by using a compiled script (EXE) as the second script.

If it works, please let me know so that I can add it to the documentation as a workaround.
Back to top
View user's profile Send private message Send e-mail
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Thu Mar 10, 2005 12:05 pm    Post subject: Reply with quote

Hi Chris,

nice idea, but on this machine it does not work. I always get an error from RunWait. I tried also the parameter @computername.

I'll test it at home again.

Tekl
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group