Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to set registry value to batch parameter

Posted on 2007-11-13
7
Medium Priority
?
882 Views
Last Modified: 2008-02-01
I need to read the registry key and retrieve the last 7 characters of that string.  

How do I set a batch file variable to equal the registry key value and then retrieve the last 7 characters of that string?
0
Comment
Question by:doyle007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 29

Expert Comment

by:matrixnz
ID: 20276884
Does it have to be batch?
0
 
LVL 29

Expert Comment

by:matrixnz
ID: 20277074
The reason I asked if you required batch is, you could use something like AutoIT to grab this quite easily.  You could also call the executable from the batch with the information for example.

Download and Install AutoIT - http://www.autoitscript.com/autoit3/

Copy the following into Notepad

#NoTrayIcon
if ProcessExists("cmd.exe") Then
      WinActivate("Command Prompt")
Else
      Exit
EndIf
$AutoIT = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIT v3\AutoIT", "InstallDir")
$InstallDir = StringRight($AutoIT, 7)
Send($InstallDir)

Save the file as something.au3 then right click something.au3 and select compile script this will create an executable in the same directory as the script called something.exe.  If you double click the file and cmd isn't opened then nothing will happen however if you open cmd and call it your should see AutoIT3 being sent to the window.

Hope that helps.

Cheers
0
 

Author Comment

by:doyle007
ID: 20277390
The reason I need it in batch is because I need to write this value out (or part of it) into a text file, based on what the value is, i.e. IF statement based on the value. Unless there is a way to pass this string back to the batch file and store it into a variable, I don't think this will work.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 29

Expert Comment

by:matrixnz
ID: 20279168
Hi Doyle

You can call the file from the script, or you could write the entire script with AutoIT.

Cheers
0
 
LVL 7

Accepted Solution

by:
Dmitrii earned 1600 total points
ID: 20280030
For command line:

SET _my_registry_path=HKLM\Software\Microsoft\DirectX
SET _my_registry_par=Version
SET _my_command='REG QUERY %_my_registry_path% /v %_my_registry_par%'
FOR /F "tokens=*" %G IN (%_my_command%) DO SET _my_res=%G
SET _last_seven=%_par:~-7%
ECHO %_last_seven%
0
 
LVL 9

Expert Comment

by:MSE-dwells
ID: 20280483
baev's solution will probably work out for you or if you'd prefer to do it with only built-in tools, ten provide a little more detail as to what the reg. key is you're trying to read (if it's binary, for example, this may not be doable period in batch.)
0
 

Author Comment

by:doyle007
ID: 20284944
Baev's solution is perfect. Thanks
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many times while working on a computer regardless of any Operating System, lag and crashes seem to creep in, hindering your working speed. Sometimes, it can also cause your work to be lost unexpectedly and as a result, you are unable to meet your de…
The way I use Experts Exchange to assist me in analyzing and diagnosing a problem is I first enter a Verbose Question at Experts Exchange like: Office 2007 will hang when opening and saving files I then launch WordPad (any text editor will do) an…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question