How RegWrite this

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

How RegWrite this

11 Nov 2018, 12:55

Up front, i've read the manuals concerning registry entries and how to make them work, tho i don't understand it fully, but maybe with some help for making this a RegWrite script for AHK, i will see what it is doing so i can understand...

Here is my registry to take ownership of file or folder...:

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\TakeOwnership]
@="Take Ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
"NeverDefault"=""

[HKEY_CLASSES_ROOT\*\shell\TakeOwnership\command]
@="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\"%1\\\" && icacls \\\"%1\\\" /grant *S-1-3-4:F /t /c /l & pause' -Verb runAs\""
"IsolatedCommand"= "powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\"%1\\\" && icacls \\\"%1\\\" /grant *S-1-3-4:F /t /c /l & pause' -Verb runAs\""


[HKEY_CLASSES_ROOT\Directory\shell\TakeOwnership]
@="Take Ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
"NeverDefault"=""

[HKEY_CLASSES_ROOT\Directory\shell\TakeOwnership\command]
@="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\"%1\\\" /r /d y && icacls \\\"%1\\\" /grant *S-1-3-4:F /t /c /l /q & pause' -Verb runAs\""
"IsolatedCommand"="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\"%1\\\" /r /d y && icacls \\\"%1\\\" /grant *S-1-3-4:F /t /c /l /q & pause' -Verb runAs\""
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: How RegWrite this

11 Nov 2018, 13:11

idk what other examples to give u(besides outright writing the script for u) other than the ones that the docs already provide
RegWrite REG_SZ, HKCR\*\shell\TakeOwnership, @, "Take Ownership"
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: How RegWrite this

11 Nov 2018, 13:23

Well if only i got an example of a few lines, that all it takes, nobody has to write the whole text, but i dont understand how to add multiple lines (like this example) or should i do this?

RegWrite REG_SZ, HKCR\*\shell\TakeOwnership, @, "Take Ownership"

RegWrite REG_SZ, HKCR\*\shell\TakeOwnership, @, "HasLUAShield"=""

RegWrite REG_SZ, HKCR\*\shell\TakeOwnership, @, "NoWorkingDirectory"=""
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: How RegWrite this

11 Nov 2018, 15:50

yes.
the only other thing to watch out for is properly escaping special AHK characters, eg. %
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: How RegWrite this

11 Nov 2018, 16:52

yep i know, i had a issue like that with an other script... so thank you :)
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: How RegWrite this

11 Nov 2018, 16:58

I think of an issue earlier where a "," had giving me problems.......

i tried to : "run some_filename.reg" in a ahk and this works, but i had to confirm the merge of the .reg file in W10, i tried to add a /S for silent, but that isn't doing it's job (no merge)

is there any other way to merge reg files witout using regwrite?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: How RegWrite this

11 Nov 2018, 18:21

Run %A_WinDir%\regedit.exe /s D:\myregfile.reg
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: How RegWrite this

11 Nov 2018, 19:02

Ok thanx..... that does the trick, while i tried this earlier, but with the difference that i didn't set the path to the right directory... i had

Run c:\windows\regedit.exe "w10people_icon.reg"

and now it's :

Run %A_WinDir%\regedit.exe "D:\USB Stick installatie windows\w10people_icon.reg"

ok, that's great, but what if the the reg file is located at another place? (e.g. i move all of the files to another location) then D:\USB...... wouldn't work anymore...

Is there a way to set a variable path or something to execute and use a %.....%

like : Run %A_WinDir%\regedit.exe "%path_to_folder\w10people_icon.reg" < - this can't be right

Sorry to bother you, but you helped me alot already :)
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: How RegWrite this

11 Nov 2018, 19:05

Code: Select all

path := "D:\USB"
Run %A_WinDir%\regedit.exe "%path%\w10people_icon.reg" 
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: How RegWrite this

11 Nov 2018, 19:09

Thank you so much for the quick and helpful hand you reached out to me !
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: How RegWrite this

13 Nov 2018, 10:20

Hi there, to give something back i've wrote something in a different way...

This script opens notepad and write the script on the fly... then it saves it to C:\Windows\Temp then it merge the reg quitly, then it closes notepad and all is done..., here is the script

btw- alot of {space} is added to make the " % { } this is due my keyboard qwerty is english at default. so you have to get rid of the {space} if " works with 1 stroke:

Code: Select all

Maak_eigendom_mappen_reg:
run "C:\Windows\System32\notepad.exe"
WinWaitActive Naamloos - Kladblok
Sleep, 100
SetKeyDelay, 1
Send Windows Registry Editor Version 5.00{ENTER}{ENTER}[HKEY_CLASSES_ROOT\*\shell\TakeOwnership]{ENTER}@="Take Ownership"{ENTER}"HasLUAShield"=""{ENTER}"NoWorkingDirectory"=""{ENTER}"NeverDefault"=""{ENTER}{ENTER}[HKEY_CLASSES_ROOT\*\shell\TakeOwnership\command]{ENTER}@="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\{ASC 00034}{ASC 00037}1\\\" {SPACE}&& icacls \\\{ASC 00034}{ASC 00037}1\\\{ASC 00034} /grant *S-1-3-4:F /t /c /l & pause'{SPACE}{SPACE}-Verb runAs\""{ENTER}"{SPACE}IsolatedCommand"= "powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\{ASC 00034}{ASC 00037}1\\\" {SPACE}&& icacls \\\{ASC 00034}{ASC 00037}1\\\" {SPACE}/grant *S-1-3-4:F /t /c /l & pause' {SPACE}-Verb runAs\""{ENTER}{ENTER}[HKEY_CLASSES_ROOT\Directory\shell\TakeOwnership]{ENTER}@="Take Ownership"{ENTER}"HasLUAShield"=""{ENTER}"NoWorkingDirectory"=""{ENTER}"NeverDefault"=""{ENTER}{ENTER}[HKEY_CLASSES_ROOT\Directory\shell\TakeOwnership\command]{ENTER}@="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\{ASC 00034}{ASC 00037}1\\\"{SPACE} /r /d y && icacls \\\{ASC 00034}{ASC 00037}1\\\" {SPACE}/grant *S-1-3-4:F /t /c /l /q & pause' {SPACE}-Verb runAs\""{ENTER}"{SPACE}IsolatedCommand"="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\{ASC 00034}{ASC 00037}1\\\"{SPACE} /r /d y && icacls \\\{ASC 00034}{ASC 00037}1\\\"{SPACE}{SPACE}/grant *S-1-3-4:F /t /c /l /q & pause' {SPACE}-Verb runAs\""{ENTER}
send ^s
send c:\windows\temp\test.reg
send {enter}
Sleep, 100
run c:\windows\regedit.exe /s c:\windows\temp\test.reg
Sleep, 100
FileDelete, c:\windows\temp\*.reg
WinClose, ahk_class Notepad
;Run %A_WinDir%\regedit.exe "%path%\reg\Add_Take_Ownership_context_menu.reg
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Rohwedder and 346 guests