Jump to content
Sign in to follow this  
RaKon

Help with an registry script

Recommended Posts

RaKon

basiclly what i am trying to do is to take a computer name that i write in a gui box and use the name in the RegWrite func, so it could change a key on a remote computer (each time i run the script i want to use a diffrent name).

i managed to copy the input from the gui txt box after i click an button in the gui, the problem is to paste it to the key path, seams the RegWrite dosent support any fanc.

here is my script:

; Include the needed libraries
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>




$Form1 = GUICreate("comp name", 269, 99, 193, 115)

$Input1 = GUICtrlCreateInput("", 72, 16, 121, 21)

$Button1 = GUICtrlCreateButton("ok", 96,56, 75, 25, 0)

GUISetState(@SW_SHOW)

While 1 
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE 
            Exit 
                Case $button1
                       ClipPut(GUICtrlRead($Input1))
                       $sData = ClipGet()
                       RegWrite("\\$sData\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "scforceoption", "REG_DWORD", "0")
Local $sVar = RegRead("\\$sData\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "scforceoption")
MsgBox($MB_SYSTEMMODAL, "status", $sVar)
    EndSwitch
WEnd; end of loop

thanks anyway

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
RaKon
Just now, Earthshine said:

Look at how registry works. The data is not in right spot

"It is possible to access remote registries by using a keyname in the form "\\computername\keyname". To use this feature you must have the correct access rights."

^taken from the help form, from that the way i wrote the key should be fine , if sData = comp name then \\$sData\HKEY_LOCAL_MACHINE... should be the right placement.

Share this post


Link to post
Share on other sites
RaKon
8 minutes ago, Earthshine said:

Look at how registry works. The data is not in right spot

https://www.autoitscript.com/autoit3/docs/functions/RegRead.htm

 

registry does not have names before the hive key

look, when i put the remote comp name insted of the sData like this RegWrite("\\sfrr1c7\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "scforceoption", "REG_DWORD", "0")

it works and change the key. so its not a placment problem, if you still think it is then could you show me what is right placement?

Share this post


Link to post
Share on other sites
Earthshine

I know what is wrong. But what is this for?


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
RaKon
Just now, Earthshine said:

I know what is wrong. But what is this for?

well...like i've said, im changing a key on a remote computers (if you asking about the key, its to release the comp from smartcard) , so each time im writing a diffrent name and it should paste it from the inputbox to where i placed the sData.

Share this post


Link to post
Share on other sites
Earthshine

you need to construct your string, then you can use it in the regwrite/read

$key  = "\\" & $sData & "\HKEY_LOCAL_MACHINE\.....

Regwrite($key, $valuename, $type, $value )

 

when you put stuff between double quotes it's a literal string, in your version it that keyname you fed it is literally "\\$sData\HKEY_LOCAL....." 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
RaKon
41 minutes ago, Earthshine said:

you need to construct your string, then you can use it in the regwrite/read

$key  = "\\" & $sData & "\HKEY_LOCAL_MACHINE\.....

Regwrite($key, $valuename, $type, $value )

 

when you put stuff between double quotes it's a literal string, in your version it that keyname you fed it is literally "\\$sData\HKEY_LOCAL....." 

Awsome its finally working! thanks a lot

Share this post


Link to post
Share on other sites
Earthshine

you are welcome. happy programming.


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.