casira Posted June 4, 2011 Share Posted June 4, 2011 İşletim Sistemine ve Tipine Göre Komut Çalıştırma Merhaba arkadaşlar.sizlere CMD-BAT toplu iş dosyaları ile komut çalıştırmanın nasıl olacağını birkaç örnekle göstereceğim. Bilmeyenler ve benim gibi merak edenler için yararlı olacağını düşünüyorum. Ben bu tip işler için Autoit kullanıyordum yani ayrı bir dosya ile uğraşıyordum fakat bunu cmd-bat ilede yapabilmek istiyordum biraz araştırmalarım sonucunda mutlu sona ulaştım. Fazla lafı uzatmayalım.İŞLETİM SİSTEMİNE GÖRE BAT-CMD DOSYALARI İLE KOMUT ÇALIŞTIRMA Sisteminiz xp ise xpye ait komutlar,vista veya 7 ise vista veya 7 komutlarının çalışması. İçerik şöyle olacak tabi siz bunları kendinizde dahada geliştirebilirsiniz. @Title BAT-CMD DOSYALARINDA ISLETIM SISTEMINE GORE KOMUT CALISTIRMA @color 2f @echo off if not exist "%userprofile%\Local Settings\Application Data" goto vista7 echo [Sisteminiz Windows XP Olabilir.] xp.exe goto finish :vista7 echo [Sisteminiz Windows Vista veya Seven (7) Olabilir.] vista7.exe goto finish :finish echo Kurulum Bitiyor.Hosca ve Dostca Kalin. kurulumbitti.exe İŞLETİM SİSTEMİ TİPİNE GÖRE (32 BİT VEYA 64 BİT) BAT-CMD DOSYALARI İLE KOMUT ÇALIŞTIRMAAlternatif 1: Sisteminiz 32 bit ise 32 bite ait komutlar,64 bit ise 64 bit komutlarının çalışması. İçerik şöyle olacak tabi siz bunları kendinizde dahada geliştirebilirsiniz. set ARCH=%PROCESSOR_ARCHITECTURE% echo %ARCH% if %ARCH%==x86 ( 32.exe ) else ( 64.exe ) Alternatif 2: Sisteminiz 32 bit ise 32 bite ait komutlar,64 bit ise 64 bit komutlarının çalışması. İçerik şöyle olacak tabi siz bunları kendinizde dahada geliştirebilirsiniz. @Title BAT-CMD DOSYALARINDA SISTEM TIPINE GORE (32 BIT VEYA 64 BIT) KOMUT CALISTIRMA @color 5f @echo off if exist "%SystemDrive%\Program Files (x86)" goto cs64 echo [32-bit Isletim Sistemi Tespit Edildi.] 32.exe goto finish :cs64 echo [64-bit Isletim Sistemi Tespit Edildi.] 64.exe goto finish :finish echo Kurulum Bitiyor.Hosca ve Dostca Kalin. kurulumbitti.exe ÖRNEK RESİMLER Quote Link to comment Share on other sites More sharing options...
casira Posted July 21, 2011 Author Share Posted July 21, 2011 Dün aklıma takıldı acaba dedim sistemin xp32bit veya xp64bit veya vista-732bit veya vista-764 bit olmasına göre nasıl komut çalıştırırım. Ve buna dair uyugulamarla çözümü buldum. Yani hem işletim sistemine göre hemde sistem tipine göre komut çalıştırma ile ilgili uygulama yaptım.Sisteminizi XP 32 bit (x86) ise bu etikete ait komutlar çalışacak.Sisteminizi XP 64 bit (x64) ise bu etikete ait komutlar çalışacak.Sisteminizi vista-7 32 bit (x86) ise bu etikete ait komutlar çalışacak.Sisteminizi vista-7 64 bit (x64) ise bu etikete ait komutlar çalışacak. BAT VEYA CMD DOSYASI İÇERİĞİ AYNEN AŞAĞIDAKİ GİB OLACAKTIR. Dilerseniz kendiniz bu örneği geliştirebilirsiniz. @Title BAT-CMD DOSYALARINDA ISLETIM SISTEMINE VE TIPINE GORE KOMUT CALISTIRMA @color 1f @echo off if not exist "%userprofile%\Local Settings\Application Data" goto vista732bit goto tipsecimi :xp32bit @echo. echo [Windows XP 32-bit Isletim Sistemi Tespit Edildi.] start /wait xp32bit.exe goto finish :vista732bit goto tipsecimi :tipsecimi if exist "%SystemDrive%\Program Files (x86)" goto 64 if exist "%userprofile%\Local Settings\Application Data" goto xp32bit @color 2f @echo. echo [Windows Vista veya Seven (7) 32-bit Isletim Sistemi Tespit Edildi.] start /wait vista732bit.exe goto finish :64 if not exist "%userprofile%\Local Settings\Application Data" goto vista764kur if exist "%SystemDrive%\Program Files (x86)" goto xp64bit :xp64bit @color 3f @echo. echo [Windows XP 64-bit Isletim Sistemi Tespit Edildi.] start /wait xp64bit.exe goto finish :vista764kur @color 4f @echo. echo [Windows Vista veya Seven (7) 64-bit Isletim Sistemi Tespit Edildi.] start /wait vista764bit.exe goto finish :finish echo Kurulum Bitiyor.Hosca ve Dostca Kalin. start /wait kurulumbitti.exe Quote Link to comment Share on other sites More sharing options...
Moderator TornadoEffect Posted July 26, 2013 Moderator Share Posted July 26, 2013 En çok sorulanlardan biri, farklı bir sorgulama ile paylaşayım. ( İşlemci tipi x86/x64 göre bat dosyası ile kurulum )Tip: *.Bat / *.CMD Script Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0 REG.exe Query %RegQry% | Find /i "x86" If %ERRORLEVEL% == 0 ( GOTO X86 ) ELSE ( GOTO X64 ) :X86 x86.exe /s -------> Programınız ve parametresi birden çok alt alta yazabilirsiniz. GOTO END :X64 x64.exe /s -------> Programınız ve parametresi birden çok alt alta yazabilirsiniz. :End Quote Link to comment Share on other sites More sharing options...
reyiz Posted July 26, 2013 Share Posted July 26, 2013 (edited) TornadoEffect'in verdiğiniz komut %PROCESSOR_ARCHITECTURE% kullanılan komuta göre daha sağlıklı çünkü %PROCESSOR_ARCHITECTURE% komutu işlemcinin 32 bit veya 64 bit olup olmadığına bakar. 64 bit işlemcili bir bilgisayara 32 bit işletim sistemi kurulmuşsa bu komut sorun yaratır. En iyisi Program Files (x86) klasörünün olup olmadığına bakmak. Edited September 6, 2013 by reyiz Quote Link to comment Share on other sites More sharing options...
Moderator TornadoEffect Posted July 26, 2013 Moderator Share Posted July 26, 2013 Daha değişik yollarıda var programfilesi sorgulayan mesala programfiles86 varsa farklı bir kurulum yoksa farklı bir kurulum yapıyor. Denemedim ama bu tarz bir şeyde yarayabilir işe: @ECHO OFF IF EXIST "%programfiles(x86)%" (GOTO 64-Bit) ELSE (GOTO 32-Bit) :32-Bit ECHO 32-Bit O/S detected GOTO END :64-Bit ECHO 64-Bit O/S detected GOTO END :END or @ECHO OFF IF EXIST "%ProgramFiles(x86)%" ( msiexec.exe /i Application64.msi /qb ) ELSE ( msiexec.exe /i Application86.msi /qb ) Quote Link to comment Share on other sites More sharing options...
Moderator TornadoEffect Posted July 27, 2013 Moderator Share Posted July 27, 2013 Sistem sürümünü ve kaç bit olduğunu sorgular ve verir:@ECHO off SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION FOR /f "tokens=1,2* delims=." %%a IN ('ver') DO ( SET WVer=%%a SET WVer=!WVer:~-1! SET WVer=!WVer!.%%b.%%c SET WVer=!WVer:]=! ) IF DEFINED ProgramFiles(x86) ( SET OSBit=x64 ) ELSE ( SET OSBit=x86 ) ECHO %WVer% %OSBit% pause Değişik bir tane:@echo off ::================================== ::variables if %PROCESSOR_ARCHITECTURE%==x86 set pro_arch=32 Bit if %PROCESSOR_ARCHITECTURE%==AMD64 set pro_arch=64 Bit if %PROCESSOR_ARCHITECTURE%==IA64 set pro_arch=Itanium 64 Bit ::================================== ver | find "4.0.950">nul if not errorlevel 1 ( set WinOS=Windows 95 goto OSis) ::================================== ver | find "4.10.1998">nul if not errorlevel 1 ( set WinOS=Windows 98 goto OSis) ::================================== ver | find "4.10.2222">nul if not errorlevel 1 ( set WinOS=Windows 98 SE goto OSis) ::================================== ver | find "4.90.3000">nul if not errorlevel 1 ( set WinOS=Windows ME goto OSis) ::================================== ver | find "NT">nul if not errorlevel 1 ( set WinOS=Windows NT goto OSis) ::================================== ver | find "5.0.2195">nul if not errorlevel 1 ( set WinOS=Windows 2000 goto OSis) ::================================== ver | find "5.1.2600">nul if not errorlevel 1 ( set WinOS=Windows XP goto OSis) ::================================== ver | find "5.2.3790">nul if not errorlevel 1 ( set WinOS=Windows 2003 goto OSis) ::================================== ver | find "6.0.6002">nul if not errorlevel 1 ( set WinOS=Windows Vista goto OSis) ::================================== ver | find "5.2.4500">nul if not errorlevel 1 ( set WinOS=Windows Home Server goto OSis) ::================================== ver | find "6.1.7600">nul if not errorlevel 1 ( set WinOS=Windows 7) ::================================== ver | find "6.2.9200">nul if not errorlevel 1 ( set WinOS=Windows 8) ::================================== :OSis echo. echo. echo.Kullandiginiz Isletim Sistemi %WinOS% %pro_arch% echo. echo. @pause Quote Link to comment Share on other sites More sharing options...
digitall Posted August 8, 2013 Share Posted August 8, 2013 (edited) Paylaşım için teşekkürler çok işime yaradı. Edited September 7, 2013 by digitall Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.