I'm trying to add a key and value to the registry but it is not working.
I tried the following:
put shell("reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v aaa")
get setRegistry("HKLM\Software\Microsoft\Windows\CurrentVersion\Run", "aaa","dword")
put it
The shell part works when I execute it from a command prompt, but not from livecode.
Thanks,
Carel
Registry editing
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Registry editing
Hi,
finally had a look into this. At first, I exported a matching key on my Win7-64 machine. Interesting is, at first, that the data type isn't DWORD (like in your example) but a string (REG_SZ) - your "aaa" is the start argument for whatever to run.
The .reg file then reads:
So I tried to translate this into LiveCode:
Returns "false". Tried then some variations - using "\" instead of "\\" in the data, renaming the key name to "Launch_MyCode", no success.
Tried the .reg file manually. And whow, it needs to run as Admin! Head -> desk ...
Started LC now as Admin, and this code worked:
Only that it ended in:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run\, but that shouldn't matter.
Case closed. ;-)
A word of advice: Don't do such if you don't provide a proper uninstaller!
If your user deletes your stack, the reg entry will survive and will bother him at each startup ... At least give him a .reg file that deletes this reg entry!
I'd do it in another way:
Have fun!
finally had a look into this. At first, I exported a matching key on my Win7-64 machine. Interesting is, at first, that the data type isn't DWORD (like in your example) but a string (REG_SZ) - your "aaa" is the start argument for whatever to run.
The .reg file then reads:
Code: Select all
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"Launch MyCode"="C:\\Program Files\\Future Software\\MyCode.exe /minimized"
Code: Select all
put setRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Launch MyCode","C:\\Program Files\\Future Software\\MyCode.exe /minimized")
Tried the .reg file manually. And whow, it needs to run as Admin! Head -> desk ...
Started LC now as Admin, and this code worked:
Code: Select all
put setRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Launch_MyCode","C:\Program Files\Future Software\MyCode.exe /minimized")
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run\, but that shouldn't matter.
Case closed. ;-)
A word of advice: Don't do such if you don't provide a proper uninstaller!
If your user deletes your stack, the reg entry will survive and will bother him at each startup ... At least give him a .reg file that deletes this reg entry!
I'd do it in another way:
- At first start, offer the user to put your program into "Autostart", and
- explain to him what you do, and
- how to remove it later.
Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!