Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for is6432os.cs

(view source code of is6432os.cs as plain text)

  1. // The initial C# code for the "plain" WMI query was generated by WMI Code Generator, Version 5.00, http://www.robvanderwoude.com/wmigen.php
  2.  
  3. using System;
  4. using System.Management;
  5. using System.Collections.Generic;
  6.  
  7. namespace Win32_Processor_Query
  8. {
  9. 	public class WMIQuery
  10. 	{
  11. 		public static int Main(string[] args)
  12. 		{
  13. 			string fullpath = Environment.GetCommandLineArgs().GetValue(0).ToString();
  14. 			string[] program = fullpath.Split('\\');
  15. 			string exename = program[program.GetUpperBound(0)];
  16. 			exename = exename.Substring(0, exename.IndexOf('.'));
  17.  
  18. 			if (args.Length > 0)
  19. 			{
  20. 				Console.OpenStandardError();
  21. 				Console.WriteLine();
  22. 				Console.WriteLine(exename + ",  Version 1.00");
  23. 				Console.WriteLine("Detect if running in a 32-bit or 64-bit OS");
  24. 				Console.WriteLine();
  25. 				Console.WriteLine("Usage:  " + exename.ToUpper() + "  [ computername ]");
  26. 				Console.WriteLine();
  27. 				Console.WriteLine("Where:  \"computername\"  is the (optional) name of a remote computer");
  28. 				Console.WriteLine("                        (default if not specified: local computer)");
  29. 				Console.WriteLine();
  30. 				Console.WriteLine("Note:   Return value (\"ErrorLevel\") 32 or 64 equals OS value");
  31. 				Console.WriteLine();
  32. 				Console.WriteLine("Written by Rob van der Woude");
  33. 				Console.WriteLine("http://www.robvanderwoude.com");
  34. 				Console.OpenStandardOutput();
  35. 				return 1;
  36. 			}
  37. 			try
  38. 			{
  39. 				string wmins = "root\\CIMV2";
  40. 				if (args.Length == 1)
  41. 				{
  42. 					wmins = "\\\\" + args[0] + "\\" + wmins;
  43.  
  44. 				}
  45.  
  46. 				UInt16 addresswidth = 0;
  47.  
  48. 				ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmins, "SELECT * FROM Win32_Processor");
  49.  
  50. 				foreach (ManagementObject queryObj in searcher.Get())
  51. 				{
  52. 					addresswidth = (UInt16) (queryObj["AddressWidth"]);
  53. 					Console.WriteLine("Windows   : {0}-bit", addresswidth);
  54. 					Console.WriteLine("Processor : {0}-bit", queryObj["DataWidth"]);
  55. 				}
  56.  
  57. 				return addresswidth;
  58. 			}
  59. 			catch (Exception e)
  60. 			{
  61. 				Console.OpenStandardError();
  62. 				Console.WriteLine("Error: " + e.Message);
  63. 				Console.WriteLine();
  64. 				Console.WriteLine("For detailed help, run: " + exename + " /?");
  65. 				Console.OpenStandardOutput();
  66. 				return 1;
  67. 			}
  68. 		}
  69. 	}
  70. }
  71.  

page last modified: 2024-04-16; loaded in 0.0187 seconds