Solved

How do I read in a version text string and extract each integer into a variable using batch file or vb.

Posted on 2013-12-29
3
264 Views
Last Modified: 2013-12-29
How do I read in a version text string and extract each integer into a variable using batch file along with the position.
example: 3.2.13.0, 3
Need to return 13

If i pass in the version number and the position i get the integer at that position.
0
Comment
Question by:josephh610
  • 2
3 Comments
 
LVL 10

Expert Comment

by:JEaston
ID: 39745147
If using VBS then the following code will do what you want:

VersionArr = Split(Wscript.Arguments.Item(0),".")
WScript.Echo VersionArr(Wscript.Arguments.Item(1)-1)

Open in new window


However, you do not need the comma to separate the arguments.

Therefore:  3.2.13.0 3
Will return 13.  (i.e. only a space, no comma).
0
 

Author Comment

by:josephh610
ID: 39745159
Cool that works, how do i assign it to a variable that I can now use externally?
0
 
LVL 10

Accepted Solution

by:
JEaston earned 350 total points
ID: 39745168
On line 2, replace WScript.Echo with 'variablename = '

E.g.
VersionArr = Split(Wscript.Arguments.Item(0),".")
versionpart = VersionArr(Wscript.Arguments.Item(1)-1)

Open in new window


You can then use that variable as you please.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now