Question Windows version and service pack information

Den Duze

Member
Hi,

From a Progress 32-bit application I'm trying to get some information about the OS.
I tried with the System.Environment but there I get "Microsoft Windows NT 6.1.7601 Service Pack 1".

I also tried with the Microsoft.Win32.Registry class but there I can only get only can get the OS productname (from under the Wow6432Node) and that's "Windows Server 2008 R2 Standard".
This looks promising but there is no node that gives me the "Service Pack 1"

I know that that info is available under CSDVersion but only in the the other Windows NT node (that is not under Wow6432Node).
It looks like I can't get that (64-bit node?) information from a 32-bit program.

Is there someone who knows how i can get the wanted information "Windows Server 2008 R2 Standard Service Pack 1" from the registry? (not with load/unlooad, I prefer a way with classes)

Thanks
 

Osborne

Active Member
Oddly enough, running Progress 32-bit on a Windows 7 64-bit Service Pack 1 PC also gives "Microsoft Windows NT 6.1.7601 Service Pack 1" for MESSAGE System.Environment:OSVersion:VersionString VIEW-AS ALERT-BOX.

I don't know if this is any help to you, but when running the code in this article I correctly get "Windows 7" and "Service Pack 1":
http://knowledgebase.progress.com/articles/Article/P25159
 

Den Duze

Member
I also saw that one but I really find that a very defficult one.
With the System.Environment and the Registry class I can get that info (almost) with a few lines of code.
The sollution in this article is almost a book long :)
Strange that this has to be so difficult ...
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
Is there someone who knows how i can get the wanted information "Windows Server 2008 R2 Standard Service Pack 1" from the registry?
So what you want is really two things:
  • the OS name (or "caption"); in this case "Microsoft Windows Server 2008 R2 Standard";
  • the service pack; in this case, "Service Pack 1".
You can use wmic commands through the shell to get both. For example, try this in a command prompt:

Code:
C:\foo>wmic os get caption
Caption
Microsoft Windows Server 2008 R2 Standard

C:\foo>wmic os get servicepackmajorversion
ServicePackMajorVersion
1

C:\foo>wmic os get servicepackminorversion
ServicePackMinorVersion
0

You can run "wmic os get /?" to return a list of properties you can query.

So you could do something like this in ABL:

Code:
define variable propname as character no-undo.
define variable osversion as character no-undo.
input through value( "wmic os get caption" ).
import unformatted propname.  /* "Caption" */
import unformatted osversion.  /* "Microsoft Windows Server 2008 R2 Standard" */
input close.
display osversion format "x(60)".

Add repeated input/import statements for any other properties you want like version number, service pack level, etc.

If you prefer, you can use the /value switch on wmic to get a single line of output in the form property=value and use ABL functions to strip off the part up to the "=".

Tip of the hat to Tom Bascom for the command and the technique. :)
 

Den Duze

Member
Thanks for that info but this still isn't what I would like.
First the input through will produce a cmd-box (what i don't want)
The servicepackmajorversion will return a 1 instead of a Service Pack 1

I still find it strange that it's not possible to get the information that is shown in the System information from some class.
I tried the OperatingSystem, System.Environment, Version, (and some other) classes but never can I get the right data.

I can get the Service Pach with System.Environment:OSVersion:ServicePack
But I can't get the OS name (Windows Server 2008 R2 Standard), when I use System.Environment:OSVersion I get Microsoft Windows NT 6.1.7601 Service Pack 1.
I know that this also provides the Majorversion.Minorversion.Build but again should i need to translate this to the recuired "Windows Server 2008 R2 Standard"

So in both case (using the Environment class or the wmic cmd) I will need to manipulate the result of the calls.
Strange that there is no way to get that information right out-of-the -box (by some class).

Again thanks for the help but it's a pitty that I can't do what I wanted (without extra manipulation)
 

Cringer

ProgressTalk.com Moderator
Staff member
Just for reference, if you don't want the cmd box to pop up, then if you use OS-COMMAND, and pipe the output to file, you can then use the COPY-LOB statement to bring the file into a long char and then parse it. Not that it helps you in this case, but just worth noting.
 

rzr

Member
There's also the "SILENT" option on the OS-COMMAND that will suppress the cmd box.

Code:
define variable propname as character no-undo.
define variable osversion as character no-undo.
os-command silent value( "wmic os get caption" ) > C:\temp\test.
input from c:\temp\test.
import unformatted propname.  /* "Caption" */
import unformatted osversion.  /* "Microsoft Windows Server 2008 R2 Standard" */
input close.
display propname osversion format "x(60)".
 

Den Duze

Member
Ah ok, I know about the silent on the os-command but I didn't know that I could use that instead of the "input through"
I never use the input through so I didn't know why this was used in the example, maybe it had some benefits.

But like you also said, it doesn't help me with my original question.
I guess my best option is to combine these: get the description with a os-command and getting the SP-information with the class

Thanks guys
 

joey.jeremiah

ProgressTalk Moderator
Staff member
you could also try the standard libraries project on the oehive.org.

Code:
{slib/slibwin.i}

message
    win_cVersionStr skip
    win_cVersionName skip
    win_iMajorVersion skip
    win_iMinorVersion skip
    win_iBuildNumber skip
    win_iPlatformId skip
    win_cCSDVersion skip
    win_iServicePackMajor skip
    win_iServicePackMinor skip
    win_iSuiteMask skip
    win_iProductType skip
    win_iReserved
view-as alert-box.

the version on the oehive.org is quite old. i'll upload a new version soon.
 

Den Duze

Member
I tried it with the currect version of slib (because there is not yet an updated version) and there I get the Service Pack 1 (that's ok) but I also get Windows 7 while it should be Windows Server R2 Standard??
 

joey.jeremiah

ProgressTalk Moderator
Staff member
Hello Den,

Can you please tell me what you get when running the code below on Windows 7 and Windows Server 2008 R2 Standard?

{slib/slibwin.i}

message win_iProductType view-as alert-box.
 

Den Duze

Member
Hey Joey,

On Windows Server 2008 R2 I can (see attachment) but I don not have a Windows 7 machine available right now.
I just switched to Windows 8.1 so ....
Is it very important to know what the resul is on a Windows 7 machine (because when needed I can install it on some VM)

Regards
 

Attachments

  • W2008R2.jpg
    W2008R2.jpg
    38.4 KB · Views: 5

joey.jeremiah

ProgressTalk Moderator
Staff member
Yes. That's exactly what I would expect.

1 = Workstation
2 = Domain Controller
3 = Server


You did restart the development environment (including eclipse) or AppServer/WebSpeed or whatever it was running on before trying it?

slibwin,p is a persistent procedure so if you don't restart your client/runtime environment then you're still using the old version.


Here's a snippet from the slibwin.p persistent procedure -

<snippet>
( if win_iProductType = {&VER_NT_WORKSTATION}
then "Windows 7"
else "Windows 2008 Server R2" )
</snippet>

If you're using the latest version then you should be able to find it in slibwin.p.

Could there be another version of slib/slibwin.p on your propath?
 

Den Duze

Member
Arrrrggg, it's my fault!
It works

I added the new slib to the propath (new direction - but I named it h:\slib) because I already had an older version in the propath (and didn't want to remove that one right now).
Checked with the 'Propath file search' that the new version was used or not (it was)
But in the runned code I used slib/slibwin.i so I did not used the new version (because the slib was in the directory added in the propath) so I get the old Windows 7 message.

Sometimes I wonder if I know what I'm doing :(

Thanks
 

joey.jeremiah

ProgressTalk Moderator
Staff member
I always wonder that about myself :)

Please also check some of the other libraries in the STandard Libraries Project (I just recently updated the backup system).

You may also want to look at my other part time project at docxfactory.com

and I'm also working on a Javascript Desktop framework for Progress that I plan to release in a couple or so months.
 
Top