Page 1 of 1

Registry values with a \ in it

Posted: Tue Oct 27, 2015 7:33 pm
by carelvos
I want to set an application to run as Administrator so I have the following code:

Code: Select all

put "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\c:\windows\test.exe" into myRegSetting
get setRegistry(myRegSetting, "RUNASADMIN")
but then it creates a subkey c: and another subkey windows and then just test.exe and runasadmin

The following works correctly, but I need the full path to the .exe

Code: Select all

put "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\test.exe" into myRegSetting
   get setRegistry(myRegSetting, "RUNASADMIN")
I know the problem must be the backslashes in "c:\windows\test.exe" but how do I go about getting it in there?

Thanks,

Carel

Re: Registry values with a \ in it

Posted: Tue Oct 27, 2015 7:47 pm
by Klaus
Hi Carel,

quick guess: escape the backslashes with a backslash?
Will move this thread to the Windows forum.


Best

Klaus

Re: Registry values with a \ in it

Posted: Tue Oct 27, 2015 8:05 pm
by carelvos
Hi Klaus,

Thanks for the quick response, but it does not work. I tried:

Code: Select all

put "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\\c:\\windows\\test.exe" into myRegSetting
   get setRegistry(myRegSetting, "RUNASADMIN")
and

Code: Select all

put "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\c:\\windows\\test.exe" into myRegSetting
   get setRegistry(myRegSetting, "RUNASADMIN")
(only one backslash after Layers)

Thanks,

Carel

Re: Registry values with a \ in it

Posted: Wed Oct 28, 2015 8:58 am
by carelvos
It seems that other program languages has the same problem - I've been going through some other forums.

I managed to achieve my objective with the following:

Code: Select all

put quote & "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" & quote into myRegSetting
   put myRegSetting & " /v " & quote & "c:\windows\test.exe" & quote & "  /d " & quote & "RUNASADMIN" & quote into myRegSetting
   put "reg add " & myRegSetting into myRegSetting
   answer myRegSetting
   get shell(myRegSetting)   
Carel

Re: Registry values with a \ in it

Posted: Wed Oct 28, 2015 1:21 pm
by Klaus
Yes, there is a reason why I am a Mac guy! :D