Code: Select all
C:\Users\D>set test=aaaIIIbbb
C:\Users\D>for /f "tokens=III delims==" %%a in ("%test%") do ( echo %%a )
"%%a" cannot be processed syntactically at this point.
Would appreciate some help. Thank you.
Moderator: DosItHelp
Code: Select all
C:\Users\D>set test=aaaIIIbbb
C:\Users\D>for /f "tokens=III delims==" %%a in ("%test%") do ( echo %%a )
"%%a" cannot be processed syntactically at this point.
Almost everything.
Code: Select all
C:\Users\steffen>set test=aaaIIIbbb
C:\Users\steffen>for /f "tokens=2 delims=$" %a in ("%test:III=$%") do @echo %a
bbb
C:\Users\steffen>
Code: Select all
C:\Users\D>FOR /F "tokens=* USEBACKQ" %g IN (`REG QUERY HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice`) do (SET "Registry1=%g") && for /f "tokens=2 delims=$" %a in ("%Registry1:Word=$%") do @echo %a
Code: Select all
C:\Users\D>(SET "Registry1=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice" ) && for /F "tokens=2 delims=$" %a in ("Progid REG_SZ $.Document.12") do @echo %a
.Document.12
C:\Users\D>(SET "Registry1=Progid REG_SZ Word.Document.12" ) && for /F "tokens=2 delims=$" %a in ("Progid REG_SZ $.Document.12") do @echo %a
.Document.12
C:\Users\D>
Code: Select all
"Progid REG_SZ Word.Document.12"
Code: Select all
C:\Users\D>set Registry1Ext=( for /f "tokens=2 delims=$" %a in ("%Registry1:Word=$%") do @echo %a )
Code: Select all
vboxcontrol guestproperty set /testproprties/myprop %Registry1Ext%
Whould have been much easier to write it in a script rather than having everything in one line for the prompt.
Code: Select all
for /f "tokens=2*" %a in ('reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v "ProgID"') do @for /f "tokens=1* delims=." %c in ("%b") do @set "Registry1Ext=.%d"
Code: Select all
for /f "tokens=2*" %a in ('reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v "ProgID"') do @for /f "tokens=1* delims=." %c in ("%b") do @vboxcontrol guestproperty set /testproprties/myprop .%d
No, I need the version with the string "Word".
Code: Select all
for /f "tokens=2*" %a in ('reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v "ProgID"') do @for /f "tokens=2 delims=$" %a in ("%Registry1:Word=$%") do @set "Registry1Ext=%a"
Code: Select all
&& vboxcontrol guestproperty set /myproperties/myproperty %Registry1Ext%
Code: Select all
for /f "tokens=2*" %a in ('reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v "ProgID"') do @for /f "tokens=2 delims=$" %a in ("%Registry1:Word=$%") do @set "Registry1Ext=%a" && D:\NT3x\vboxcontrol guestproperty set /myproperties/myproperty %Registry1Ext%
Code: Select all
C:\Users\D>for /f "tokens=2*" %a in ('reg query "HKCU\SOFTWARE\Microsoft\Windows
\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v "ProgID"') do @for /f "to
kens=2 delims=$" %a in ("%Registry1:Word=$%") do @set "Registry1Ext=%a" && D:\NT
3x\vboxcontrol guestproperty set /myproperties/myproperty %Registry1Ext%
Oracle VM VirtualBox Guest Additions Command Line Management Interface Version 6
.1.14
(C) 2008-2020 Oracle Corporation
All rights reserved.
C:\Users\D>echo %Registry1Ext%
.Document.12
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
C:\Users\D>for /f "tokens=2*" %a in ('reg query "HKCU\SOFTWARE\Microsoft\Windows
\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v "ProgID"') do @for /f "to
kens=2 delims=$" %a in ("%Registry1:Wo=$%") do @set "Registry1Ext=%a" && D:\NT3x
\vboxcontrol guestproperty set /myproperties/myproperty %Registry1Ext%
Oracle VM VirtualBox Guest Additions Command Line Management Interface Version 6
.1.14
(C) 2008-2020 Oracle Corporation
All rights reserved.
C:\Users\D>echo %Registry1Ext%
rd.Document.12
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
C:\Users\D>
Take a look at DELAYEDEXPANSION ( SETLOCAL /? and SET /?).
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=%
Unfortunately the second example from post <14 Feb 2021 17:57> seems not to work:
Code: Select all
C:\Users\D>for /f "tokens=2*" %a in ('reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v "ProgID"') do @for /f "to
kens=1* delims=." %c in ("%b") do @vboxcontrol guestproperty set /testproprties/myprop .%d
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:
Code: Select all
C:\Users\D>reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v "ProgID"
Code: Select all
ProgID REG_SZ Word.Document.12
Code: Select all
vboxcontrol guestproperty set /myproperties/myproperty <here comes the part, I want to have in the property myproperty>
Code: Select all
C:\Users\D>reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice" /v "ProgID"
Code: Select all
ProgID REG_SZ Word.Document.12
Thank you.Eureka! wrote: ↑14 Feb 2021 14:15(Untested)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=%
Code: Select all
vboxcontrol guestproperty set /myproperties/myproperty %YOURVAR%
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%
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%
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
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%
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
Code: Select all
Set example=0
For /L %%a in (1 1 3)Do (
Set example=%%a
Echo(output:%example% actual:%%a
)
Code: Select all
Set example=0
For /L %%a in (1 1 3)Do (
Set example=%%a
Call Echo(output:%%example%%
)
Code: Select all
set BUFFER=%x& call set YOURVAR=%BUFFER:*Word=%& call vboxcontrol guestproperty set /myproperties/myproperty %YOURVAR%
Code: Select all
set BUFFER=%x& call vboxcontrol guestproperty set /myproperties/myproperty %BUFFER:*Word=%
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 vboxcontrol guestproperty set /myproperties/myproperty %BUFFER:*Word=%
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 vboxcontrol guestproperty set /myproperties/myproperty %BUFFER:*Wor=%
-> Works as expected:Eureka! wrote: ↑15 Feb 2021 02:57What happens if you run these two commands on the CMD prompt?:
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 vboxcontrol guestproperty set /myproperties/myproperty %BUFFER:*Word=% 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 vboxcontrol guestproperty set /myproperties/myproperty %BUFFER:*Wor=%
Thank you. The code with this replacement works now also in the same cmd-window. So I can now in this new code chanage <%BUFFER:*Word=> into <%BUFFER:*Wo=> and it works also in the same cmd-window.Eureka! wrote: ↑15 Feb 2021 02:57You can skip the extra call-statement, which complicates things, by replacingwith:Code: Select all
set BUFFER=%x& call set YOURVAR=%BUFFER:*Word=%& call vboxcontrol guestproperty set /myproperties/myproperty %YOURVAR%
Code: Select all
set BUFFER=%x& call vboxcontrol guestproperty set /myproperties/myproperty %BUFFER:*Word=%
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 vboxcontrol guestproperty set /myproperties/myproperty %BUFFER:*Word=%