Hack Forums
Help With Detecting OS Programmatically - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: Help With Detecting OS Programmatically (/showthread.php?tid=5814245)



Help With Detecting OS Programmatically - FantaŠec - Mar 21, 2018

Does anyone have any ideas on detecting whether a system is a Windows 10S system programmatically (Javascript/PHP/etc)? I have attempted to use javascript (navigator.useragent, and a few others), with no success.  
The problem comes into play that Windows 10S does not allow any application that is not in the MS App Store to be installed, so I cant just have a user run the program and have it report back, because it wont execute due to the MS restriction. Any ideas would be hugely appreciated.


RE: Help With Detecting OS Programmatically - Nachfolger - Mar 21, 2018

I'll be damned if you manage to get a markup language (HTML) to detect an OS.

OT: See the below answer
PHP Code

<?php 
$user_agent 
= $_SERVER['HTTP_USER_AGENT'];

function 
getOS() { 
    global 
$user_agent;
    
$os_platform  = "Unknown OS Platform";
    
$os_array     = array(
                          
'/windows nt 10/i'      =>  'Windows 10',
                          
'/windows nt 6.3/i'     =>  'Windows 8.1',
                          
'/windows nt 6.2/i'     =>  'Windows 8',
                          
'/windows nt 6.1/i'     =>  'Windows 7',
                          
'/windows nt 6.0/i'     =>  'Windows Vista',
                          
'/windows nt 5.2/i'     =>  'Windows Server 2003/XP x64',
                          
'/windows nt 5.1/i'     =>  'Windows XP',
                          
'/windows xp/i'         =>  'Windows XP',
                          
'/windows nt 5.0/i'     =>  'Windows 2000',
                          
'/windows me/i'         =>  'Windows ME',
                          
'/win98/i'              =>  'Windows 98',
                          
'/win95/i'              =>  'Windows 95',
                          
'/win16/i'              =>  'Windows 3.11',
                          
'/macintosh|mac os x/i' =>  'Mac OS X',
                          
'/mac_powerpc/i'        =>  'Mac OS 9',
                          
'/linux/i'              =>  'Linux',
                          
'/ubuntu/i'             =>  'Ubuntu',
                          
'/iphone/i'             =>  'iPhone',
                          
'/ipod/i'               =>  'iPod',
                          
'/ipad/i'               =>  'iPad',
                          
'/android/i'            =>  'Android',
                          
'/blackberry/i'         =>  'BlackBerry',
                          
'/webos/i'              =>  'Mobile'
                    
);

    foreach (
$os_array as $regex => $value)
        if (
preg_match($regex, $user_agent))
            
$os_platform = $value;
    return 
$os_platform;
} 
https://stackoverflow.com/questions/18070154/get-operating-system-info


RE: Help With Detecting OS Programmatically - FantaŠec - Mar 21, 2018

Unfortunately the useragent Windows 10S sends up is identical to Windows 10. I am attempting to find a way to figure out which is which from a web instance.