Registry values with a \ in it

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
carelvos
Posts: 19
Joined: Tue Jul 14, 2015 5:21 pm

Registry values with a \ in it

Post by carelvos » Tue Oct 27, 2015 7:33 pm

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

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Registry values with a \ in it

Post by Klaus » Tue Oct 27, 2015 7:47 pm

Hi Carel,

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


Best

Klaus

carelvos
Posts: 19
Joined: Tue Jul 14, 2015 5:21 pm

Re: Registry values with a \ in it

Post by carelvos » Tue Oct 27, 2015 8:05 pm

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

carelvos
Posts: 19
Joined: Tue Jul 14, 2015 5:21 pm

Re: Registry values with a \ in it

Post by carelvos » Wed Oct 28, 2015 8:58 am

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

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Registry values with a \ in it

Post by Klaus » Wed Oct 28, 2015 1:21 pm

Yes, there is a reason why I am a Mac guy! :D

Post Reply

Return to “Windows”