Monday, May 22, 2017

Find the OS architecture from the command line

Find the OS architecture from the command line. Oh, how many ways are there to do this? 10-15? Maybe more, here is the the easy one, from the command line type "SET PR"

Windows 10 - X64


Windows 2003 - X86



Other ways, just for a laugh (I googled these):

1:

reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT
if %OS%==32BIT echo This is a 32bit operating system
if %OS%==64BIT echo This is a 64bit operating system
 

2:

:CheckOS
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)

:64BIT
echo 64-bit...
GOTO END

:32BIT
echo 32-bit...
GOTO END

:END
 

3:

*** Start ***
@echo off

Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry% > checkOS.txt
Find /i "x86" < CheckOS.txt > StringCheck.txt

If %ERRORLEVEL% == 0 (
    Echo "This is 32 Bit Operating system"
) ELSE (
    Echo "This is 64 Bit Operating System"
)
*** End ***
 

4:

wmic os get osarchitecture
 

5:

(set | find "ProgramFiles(x86)" > NUL) && (echo "%ProgramFiles(x86)%" | find "x86") > NUL && set bits=64 || set bits=32
  

6:

echo %PROCESSOR_ARCHITECTURE%
 

7:

check for the presence of 
%SYSTEMROOT%\Program Files(x86)

8:

systeminfo | findstr /I type: 

9:

Start-> Run -> winmsd.exe
Under "System Summary"/ System Type you can find the OS version
X64 -> 64 Bit
X86 -> 32 Bit

10:

:arch
set p | findstr /i AMD64 > nul
if not errorlevel 1 goto no64
goto eof
:no64
code to execute
:eof 

Sunday, May 21, 2017

Delete files older than N days as a service

I have found an issue with (perhaps Microsoft Office 365 client telemetry) that is generating many .CAB and .LOG files that go in my case to the users TEMP folder.

I am sure with more time I could stop it, but as most computers are SSD a space limited, I created a scheduled task for the user that deletes them.

If you just want to see what will be deleted this is the command.

CD %TEMP%
forfiles -p %temp% -s -m *.* /D -5 /C "cmd /c echo @FILE"

Create a CMD file and run this:

This is the delete:
 
CD %TEMP%
forfiles -p %temp% -s -m *.* /D -5 /C "cmd /c del @FILE /f /q"


Blog Archive