Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

There are a few answers here. They tend to be much more Windows-specific than Perl-specific, but then that means they work from any language.

http://ss64.com/nt/ver.html has a batch script which uses the ver command interpreter built-in command which will tell you the version and the processor architecture. I know a command line seems archaic to some Windows users, but it can still be useful. I'm sure you could find a way to do this without the batch file based on the information provided.

@Echo off Setlocal :: Get windows Version numbers For /f "tokens=2 delims=[]" %%G in ('ver') Do (set _version=%%G) For /f "tokens=2,3,4 delims=. " %%G in ('echo %_version%') Do (set _ma +jor=%%G& set _minor=%%H& set _build=%%I) Echo Major version: %_major% Minor Version: %_minor%.%_build% if "%_major%"=="5" goto sub5 if "%_major%"=="6" goto sub6 Echo unsupported version goto:eof :sub5 ::Winxp or 2003 if "%_minor%"=="2" goto sub_2003 Echo Windows XP [%PROCESSOR_ARCHITECTURE%] goto:eof :sub_2003 Echo Windows 2003 or XP 64 bit [%PROCESSOR_ARCHITECTURE%] goto:eof :sub6 if "%_minor%"=="1" goto sub7 Echo Windows Vista or Windows 2008 [%PROCESSOR_ARCHITECTURE%] goto:eof :sub7 Echo Windows 7 or Windows 2008 R2 [%PROCESSOR_ARCHITECTURE%] goto:eof

http://ss64.com/ has command lists or statement dictionaries for:

They also have other information like links to the relevant MS KB entries when those apply, a Unicode character reference, an all-JavaScript password generator, and a forum. I'm not affiliated, not even as a forum member or regular user. I do enjoy their low-bandwidth and easily read pages when I just need to look up help for a command I don't have on the system I'm using at the moment. All the stuff here that is pulled from SS64 is of course copyright SS64. The site is even Creative Commons ShareAlike (Attribution-Non-Commercial-Share Alike 2.0 UK: England & Wales), so I have a local mirror or three of the whole site for my own use.It's only 14 MB -- see what I mean about low-bandwidth? Still, of course, if you're taking more than one complete mirror mirror your first mirror to do that.

If you can figure out all you need by parsing the environment variable %PROCESSOR_ARCHITECTURE% (which says x86 or IA64) then that'll be handy, but I think that returns x86 for 32-bit applications on 64-bit OSes. But then there's the Windows-on-Windows shim, and it has its own variable...

http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx has a howto for determining if a 32-bit program is running on 64-bit Windows by using both PROCESSOR_ARCHITECTURE and PROCESSOR_ARCHITEW6432 but admits it's a bit of tickling the wizard.

There's also the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE registry key. You can even read this from a command line of:

reg query "HKLM\System\CurrentControlSet\Control\Session Manager\Envir +onment" /v PROCESSOR_ARCHITECTURE

Then there's the Microsoft Knowledge Base article on bit width of the OS: http://support.microsoft.com/kb/556009 complete with its own batch file which checks the registry a different way.

You Windows folks might want to give some love to configure and to Config so that $Config{'archname'} and $Config{'archname64'} end up being useful (if they're not now, which I assume is the case since nobody mentioned those). Having separate Win32 modules is all well and good for many things in areas in which you're trying to do complex things in ways Thompson, Kernighan, Ritchie, Pike, et al never intended. Yet I think it's not too much to ask that Perl users on Windows can tell easily what "Windows" means at the moment. Just expect the porters to not think it's too much to ask for Windows folks who care to do the work. Heck, even $^O might be made to return the information you want if you can provide the patch.

Hey, I'm a Linux guy. Who says it's hard to find relevant information using search engine? ;-) (Okay, I admit, I was an old DOS hand part of last century, and part of knowing what to search for was based on that.)


In reply to Re: How to know the Windows OS that perl is running on by mr_mischief
in thread How to know the Windows OS that perl is running on by alain_desilets

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 22:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found