0

Is there a way to determine if the machine is running an Intel or AMD processor through the Windows command line (so it can be placed in a Batch file)? I am trying to make an installation script for some drivers, and decided that using "Devcon" is the best way, but it requires the correct architecture to run.

Additionally, is there a better way to determine if a computer is running 32-bit or 64-bit versions of Windows besides checking for the existence of "Program Files (x86)"? That is the approach I have taken thus far.

I'm not new to programming or scripting, but I am very new to Windows CMD (I'm primarily a Linux user).

Thanks guys! I can give more information if you need it.

Chris
  • 1,569
  • 2
  • 11
  • 18
  • Why are you trying to install drivers from a script? A real installer would be a better solution (and the driver installation will probably fail on most current Windows systems anyway, because you can't sign a script file). The installer would allow you to install the proper files based on the processor, architecture, and OS version. – Ken White Jan 25 '13 at 02:01
  • What is the best way to make a "real installer"? Visual Studio installer creator? I'm definitely open to ideas. And yes, the window saying "Driver is not signed, continue anyway?" would pop up. Sorry for my lack of knowledge about this. You can just point me to a source and I can learn it myself (and make an answer and I will give you the green check). – Chris Jan 25 '13 at 02:04
  • 1
    There are free installation builders (or the VS installer creator). Inno Setup is free, for instance, and is pretty extensible. Search this site for "Windows Installers" or "[windows] installers", as there have been many posts on the subject. – Ken White Jan 25 '13 at 02:10
  • You can start with [this link] which discusses Inno Setup vs. Wix. There are other links there in the "Related" list to the right. :-) – Ken White Jan 25 '13 at 02:12
  • Your link didn't work. Maybe add an "Answer" with all the info so it can be correctly documented? Thanks! – Chris Jan 25 '13 at 02:13
  • Oops! Got distracted. Try [this link](http://stackoverflow.com/q/6245260/62576) instead. :-) An answer wouldn't be appropriate, as that's not the question you asked. (You asked about determining the processor manuf. through the command line, so answers should provide that information.) – Ken White Jan 25 '13 at 02:15

3 Answers3

3

I think the Batch file below get the info you want:

@echo off
for /F "skip=1 delims=" %%a in ('wmic cpu get name') do set cpu=%%a
for /F "skip=1 delims=^|" %%a in ('wmic os get name') do set os=%%a
echo CPU: "%cpu%
echo OS:  "%os%"

For example, in my (very old) computer, it shows:

CPU: "Intel(R) Pentium(R) M processor 1.20GHz
OS:  "Microsoft Windows XP Professional"

I hope it helps.

Antonio

Aacini
  • 65,180
  • 12
  • 72
  • 108
2
wmic cpu get name,CurrentClockSpeed,MaxClockSpeed

Source: http://www.windows7hacker.com/index.php/2011/10/how-to-find-out-bios-motherboard-and-cpu-info-from-command-line/

Hitman47
  • 421
  • 4
  • 8
  • It looks like this could be a good option, but from your source, it looks like it displays a whole bunch of information thats unnecessary (and difficult to parse for a simple IF statement). Is there a way to cut down the output (or parse it)? In Linux, I would obviously run it through some regex or something, but I've never used Windows for something that complex, so I don't even know if it would work. – Chris Jan 25 '13 at 01:53
1

Here's my solution, though it only checks the architecture:

for /f "tokens=* delims=AMDx" %%a in ('"echo %processor_architecture%"') do (set arc=%%a & echo %arc%)

It returns either 86 or 64, and sets the variable "arc" to equal the respective architecture...

I find this especially useful for integrating Nirsoft tools into my scripts, because many of them are built for either 86 or 64.

user1
  • 153
  • 1
  • 8