Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
zugort
- Posts: 2
- Joined: 21 Feb 2011 10:37
#1
Post
by zugort » 22 Feb 2011 06:10
Hey guys,
At first I have to say I'm new to Batch programming.

I have a question:
Is it possible to get from the Standard registry entry at
"HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PHPScript\Shell\Open\Command",
which looks like "C:\xampp\php\php.exe -f "%1" -- %*" to only get the exe file and the path to it (And not all the other stuff)?
And finally is it possible to save that in a variable?
I'm sorry, if I didn't express it in the right way. So feel free to ask

Greetings from Germany,
zugort

-
zugort
- Posts: 2
- Joined: 21 Feb 2011 10:37
#2
Post
by zugort » 22 Feb 2011 07:47
I did it:
for /F "tokens=3" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PHPScript\Shell\Open\Command"') do set var1=%%G
I almost had it like this, but I used delims, which was obviously wrong
Thank you for your patience 'though

Greetings,
zugort
-
xl1000
- Posts: 10
- Joined: 01 Feb 2011 06:10
#3
Post
by xl1000 » 22 Feb 2011 11:15
Interesting topic

How about this one:
Code: Select all
reg QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\txtfile\Shell\Open\Command"
The output is:
Code: Select all
! REG.EXE VERSION 3.0
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\txtfile\Shell\Open\Command
<NO NAME> REG_EXPAND_SZ "C:\Program Files\Notepad++\notepad++.exe" %1
Here the file is located in a path containing spaces.
-
aGerman
- Expert
- Posts: 4705
- Joined: 22 Jan 2010 18:01
- Location: Germany
#4
Post
by aGerman » 22 Feb 2011 12:45
Hmm. Maybe not the best way, but we could use ".exe" as string separator.
Code: Select all
@echo off &setlocal
for /f "tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Classes\txtfile\Shell\Open\Command" /ve') do (
set "command=%%~b"
setlocal enabledelayedexpansion
for /f "delims=?" %%c in ("!command:.exe=?!") do (
endlocal
set "appfullname=%%c.exe"
)
)
echo %appfullname%
pause
Regards
aGerman
-
xl1000
- Posts: 10
- Joined: 01 Feb 2011 06:10
#5
Post
by xl1000 » 22 Feb 2011 15:27
Close, but no cigar yet...
Output is :
Code: Select all
REG_EXPAND_SZ "C:\Program Files\Notepad++\notepad++.exe
Changing the "tokens=
2*" into "tokens=
3*" did the trick
The output now becomes :
Code: Select all
C:\Program Files\Notepad++\notepad++.exe
So, now the cigar is earned ... thnx..

-
aGerman
- Expert
- Posts: 4705
- Joined: 22 Jan 2010 18:01
- Location: Germany
#6
Post
by aGerman » 22 Feb 2011 16:22
Yeah

I didn't consider the command output that you wrote. Your
<NO NAME> is my
(Standard). As you can see it's language dependent how many spaces the string contains
Regards
aGerman