Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
DOS/Other
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard network printer problem ram registry router security slow software sound toshiba trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > DOS/Other >
Solved: Script issue with displayname and version

Reply  
Thread Tools
raven6988's Avatar
Junior Member with 28 posts.
 
Join Date: Feb 2010
Experience: Intermediate
09-Feb-2010, 08:57 AM #16
Nope the equal sign was a fat finger. All my code is on a closed network system so I have to hand jam it all.

Something like this?

For /F "Tokens=2* skip=2" %%I In ('REG Query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{0000C40F-A401-4C9C-AF3E-0382E92E1E22} /v DisplayVersion') If %%J=="4.21.4.004" echo Program A version %%J is installed.
If %%J=="4.11.4.022" echo Program B ver %%J is installed.

Or do I have the If statements wrong?

Sorry if this seems like I am new to this. I am relearning it all after being away for so long.
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
09-Feb-2010, 09:08 AM #17
So the Program Name is different depending on the Version?
Is the DisplayName value in the registry for both versions the same? If not, just use that value instead of the If statements.

The If statements should be set up like this:
Code:
For /F "Tokens=2* skip=2" %%I In ('REG Query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{0000C40F-A401-4C9C-AF3E-0382E92E1E22} /v DisplayVersion') Do (
If %%J=="4.21.4.004" Echo Program A version %%J is installed.
If %%J=="4.11.4.022" Echo Program B ver %%J is installed.
)
raven6988's Avatar
Junior Member with 28 posts.
 
Join Date: Feb 2010
Experience: Intermediate
09-Feb-2010, 09:19 AM #18
Yes the DisplayName is exactly the same in Both that is why I have to go by the DisplayVersion.

It works. Thank you very much.

Is there a way to write the If statement so that instead of looking for the full version number I can use 4.11 and a wildcard to say anything after this is not needed? or do I need to use the full versions?

If %%J=="4.11.4.022" Echo Program B ver %%J is installed.

If %%J=="4.11*" Echo Program B ver %%J is installed?




I should be able to use this in a couple other locations with other programs but I can use the DisplayName to distinguish those..
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
09-Feb-2010, 09:25 AM #19
Code:
For /F "Tokens=2* skip=2" %%I In ('REG Query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{0000C40F-A401-4C9C-AF3E-0382E92E1E22} /v DisplayVersion') Do Set _Version=%%J
If "%_Version:~0,4%"=="4.21" Echo Program A version %_Version% is installed.
If "%_Version:~0,4%"=="4.11" Echo Program B version %_Version% is installed.
)
That should do it. If you don't want to display the full version, use the same clause in the Echo Statement: "%_Version:~1,4%" instead of %_Version%
And to display just the first three digits
Code:
For /F "Tokens=2* skip=2" %%I In ('REG Query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{0000C40F-A401-4C9C-AF3E-0382E92E1E22} /v DisplayVersion') Do Set _Version=%%J
If "%_Version:~0,4%"=="4.21" Echo Program A version %_Version:~0,4% is installed.
If "%_Version:~0,4%"=="4.11" Echo Program B version %_Version:~0,4% is installed.
)
Or just hard code in the 4.11 or 4.22 in the Echo statement portion
__________________
Microsoft MVP - Windows Expert - Consumer
Of course I know all the answers ; I just don't always match the answers to the right questions


Last edited by TheOutcaste; 09-Feb-2010 at 09:45 AM.. Reason: Corrected substring range
raven6988's Avatar
Junior Member with 28 posts.
 
Join Date: Feb 2010
Experience: Intermediate
09-Feb-2010, 09:40 AM #20
Ok so while no errors popped up

Nothing now shows thru the echos...
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
09-Feb-2010, 09:43 AM #21
Opps, was thinking the quotes were part of the data. Quotes are always tripping me up. Should be "%_Version:~0,4%"
I'll edit the post
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
09-Feb-2010, 09:43 AM #22
Never hurts to keep re-posting your code. If you fat fingered it once, you could have done it again.
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
09-Feb-2010, 09:45 AM #23
Quote:
Originally Posted by TheOutcaste View Post
Opps, was thinking the quotes were part of the data. Quotes are always tripping me up. Should be "%_Version:~0,4%"
I'll edit the post
Zero really is a number!
I thought you dreamed in binary!
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
09-Feb-2010, 09:50 AM #24
I will have to say that this thread has brought out a lot of good batch coding examples for Raven.
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
09-Feb-2010, 09:55 AM #25
Quote:
Originally Posted by raven6988 View Post
Ok so while no errors popped up

Nothing now shows thru the echos...
Just one more point and Jerry usually makes this comment as well. When you don't see your intended output and you have echo turned off, that is usually a good time to turn echo back on at the top of your script and watch it step thru your code. You probably would have instantly seen that your version number was truncated at the beginning.
raven6988's Avatar
Junior Member with 28 posts.
 
Join Date: Feb 2010
Experience: Intermediate
09-Feb-2010, 10:15 AM #26
Thank you for all the help.

I see the truncated value now that you mentioned it.

Thank you both. As you said, There is alot of good coding references I will be using in the future.

Thank you both.

I will be back with more questions as I have them. Especially since this is the only place I have been able to find that actually is able to answer my questions.
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
09-Feb-2010, 10:23 AM #27
Batch is a lost art form!
raven6988's Avatar
Junior Member with 28 posts.
 
Join Date: Feb 2010
Experience: Intermediate
09-Feb-2010, 11:17 AM #28
Yes it is.... and trying to relearn is even harder since most of the information out there is either generalizations or over-written.

What happened to the examples of real lines of batch codes and explanations of what each did??
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 10:09 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.