1.

Solve : Regedit, to dos variable??

Answer»

There's a specific variable i want to GET from the registery.
Let's say the lastgamename used.

REG QUERY HKEY_CURRENT_USER\Software\Valve\Steam /v LastGameNameUsed

If i use this the output will be
Quote

! REG.EXE VERSION 3.0

HKEY_CURRENT_USER\Software\Valve\Steam
LastGameNameUsedREG_SZogelami
By that set q=REG QUERY HKEY_CURRENT_USER\Software\Valve\Steam /v LastGameNameUsed
Will not do it.

I want it only to be
ogelami

And i want to be able to use it, like in an ECHO.
echo helo %q%
That prints "Hello ogelami!"Code: [Select]
@echo off
set regcommand=REG QUERY HKEY_CURRENT_USER\Software\Valve\Steam /v
set keyname=LastGameNameUsed
for /f "tokens=1,2,3 delims=<TAB>" %%A in ( ' %regcommand% %keyname% ^| find "%keyname%" ' ) do set LastName=%%C
echo Hello %LastName%

Important note: Do NOT merely copy and paste this. Replace in the 4th line with a TAB character, obtained by pressing the key of that NAME.

Thank you times and times ! it worked fine!
Another happy customer! Glad to hear it worked. Good luck, my friend!
Thank you, there's anoter small thing i need help with.

When i receive a directory variable, the slashes are just regular slashes, i want them to become backslashes =), any solution?Quote from: ogelami on October 12, 2008, 05:11:57 AM
Thank you, there's anoter small thing i need help with.

When i receive a directory variable, the slashes are just regular slashes, i want them to become backslashes =), any solution?


This is a path name got from the REGISTRY?

You mean they are forward slashes? like this / ? And you want them to be back slashes like this \ ? Please explain.
Quote from: Dias de verano on October 12, 2008, 05:16:10 AM
Quote from: ogelami on October 12, 2008, 05:11:57 AM
Thank you, there's anoter small thing i need help with.

When i receive a directory variable, the slashes are just regular slashes, i want them to become backslashes =), any solution?


This is a path name got from the registry?

You mean they are forward slashes? like this / ? And you want them to be back slashes like this \ ? Please explain.


yes, excatly
if i get "SteamPath" instead "LastGameNameUsed" it will return in C:/Program/Steam
what i want is it to be C:\Program\Steam
to replace one character or string in a variable by another:

To replace X with Y in %myname%:

Code: [Select]set myname=%myname:X=Y%
and to replace Z with nothing (remove all the Zs) in UncleName:

Code: [Select]set UncleName=%UncleName:Z=%
and to replace cat with dog in %animalname%:

Code: [Select]set animalname=%animalname:cat=dog%
Thus:

Code: [Select]C:\>set myname=aXa

C:\>echo %myname%
aXa

C:\>set myname=%myname:X=Y%

C:\>echo %myname%
aYa
and

Code: [Select]C:\>set pathname=c:/program/steam

C:\>echo %pathname%
c:/program/steam

C:\>set pathname=%pathname:/=\%

C:\>echo %pathname%
c:\program\steam
Works both at prompt and in a batch

thank you!


Discussion

No Comment Found