Eureka! wrote: ↑14 Feb 2021 14:15
Code: Select all
for /f "usebackq skip=1 tokens=3 delims= " %x in (`reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v progid`) do set BUFFER=%x& call set YOURVAR=%BUFFER:*Word=%
(Untested)
Thank you.
Your code works in a way, that now I have in the variable YOURVAR what I need.
But:
I need the content of YOURVAR, at the end in my property "myproperty":
Code: Select all
vboxcontrol guestproperty set /myproperties/myproperty %YOURVAR%
So I have taken your code and have expanded it (scroll at the end):
Code: Select all
for /f "usebackq skip=1 tokens=3 delims= " %x in (`reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v progid`) do set BUFFER=%x& call set YOURVAR=%BUFFER:*Word=%& call vboxcontrol guestproperty set /myproperties/myproperty %YOURVAR%
This expanded code seems to work. But only one time in the same cmd-window. When I change ...%BUFFER:*Word=%&... into ...%BUFFER:*Wor=%&... and start the modified code in the same cmd-window, then the property "myproperty" remains the same. Strange!
This is to demonstrait, what exactly happens, when I use the code two times in the same cmd-window, but modify it between the two times:
This is what I typed in my cmd-window:
Code: Select all
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\D>for /f "usebackq skip=1 tokens=3 delims= " %x in (`reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v progid`) do set BUFFER=%x& call set YOURVAR=%BUFFER:*Word=%& call vboxcontrol guestproperty set /myproperties/myproperty %YOURVAR%
This is the output an a test, what is in the property "myproperty" now:
Code: Select all
C:\Users\D>set BUFFER=Word.Document.12 & call set YOURVAR=%BUFFER:*Word=% & call vboxcontrol guestproperty set /myproperties/myproperty %YOURVAR%Oracle VM VirtualBox Guest Additions Command Line Management Interface Version 6.1.2
(C) 2008-2020 Oracle Corporation
All rights reserved.
C:\Users\D>vboxcontrol guestproperty get /myproperties/myproperty
Oracle VM VirtualBox Guest Additions Command Line Management Interface Version 6.1.2
(C) 2008-2020 Oracle Corporation
All rights reserved.
Value: .Document.12
-> It's ".Document.12" as it sould be.
Now I modify the code as mentioned (I change ...%BUFFER:*Word=%&... into ...%BUFFER:*Wor=%&...).
This is what I typed in the same cmd-window below the output from above:
Code: Select all
C:\Users\D>for /f "usebackq skip=1 tokens=3 delims= " %x in (`reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v progid`) do set BUFFER=%x& call set YOURVAR=%BUFFER:*Wor=%& call vboxcontrol guestproperty set /myproperties/myproperty %YOURVAR%
This is the output an a test, what is in the property "myproperty" now:
Code: Select all
C:\Users\D>set BUFFER=Word.Document.12 & call set YOURVAR=d.Document.12 & call
vboxcontrol guestproperty set /myproperties/myproperty .Document.12
Oracle VM VirtualBox Guest Additions Command Line Management Interface Version 6.1.2
(C) 2008-2020 Oracle Corporation
All rights reserved.
C:\Users\D>vboxcontrol guestproperty get /myproperties/myproperty
Oracle VM VirtualBox Guest Additions Command Line Management Interface Version 6
.1.2
(C) 2008-2020 Oracle Corporation
All rights reserved.
Value: .Document.12
-> As you can see it's again ".Document.12" . But it should be now "d.Document.12", after the modification.
(But it's not serious, because I guess, whenever I start the code again, then anyway a new cmd-window will start.
But it's strange behaviour.)