| View previous topic :: View next topic |
| Author |
Message |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Wed Mar 09, 2005 7:47 am Post subject: Admin-rights for Registry |
|
|
Hello Chris,
is it possible to enhance the Registry-Commands, that it is possible to specify a username and password?
Tekl |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Wed Mar 09, 2005 8:15 am Post subject: |
|
|
| AHK's RunAs ??? |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Wed Mar 09, 2005 9:25 am Post subject: |
|
|
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 |
|
 |
BoBo Guest
|
Posted: Wed Mar 09, 2005 9:48 am Post subject: |
|
|
@ 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.  |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Wed Mar 09, 2005 1:48 pm Post subject: |
|
|
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 |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Wed Mar 09, 2005 3:37 pm Post subject: |
|
|
| Who is foreigner to whom? (Wir sind nur scheiß' Ausländer) |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Wed Mar 09, 2005 3:55 pm Post subject: Re: Admin-rights for Registry |
|
|
| 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 |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Wed Mar 09, 2005 3:57 pm Post subject: |
|
|
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. Even though we're all "foreigners" ourselves, excluding those of Native American descent. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Wed Mar 09, 2005 4:24 pm Post subject: |
|
|
| In a .com (not .de) forum nobody should be foreigner. But we are off topic now… |
|
| Back to top |
|
 |
Nemroth
Joined: 07 Sep 2004 Posts: 262 Location: France
|
Posted: Wed Mar 09, 2005 5:54 pm Post subject: |
|
|
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à !  |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Wed Mar 09, 2005 6:18 pm Post subject: |
|
|
| 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 |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Wed Mar 09, 2005 11:23 pm Post subject: |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Thu Mar 10, 2005 12:25 am Post subject: |
|
|
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 |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Thu Mar 10, 2005 12:05 pm Post subject: |
|
|
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 |
|
 |
|