Langsung ke konten utama

BATCH FILE PROGRAMMING





Batch File Programing  merupakan perintah dasar yang ada pada sistem operasi Windows. Dengan mempelajari beberapa perintah batch pada komputer, nantinya anda akan bisa membuat sebuah program penolong ataupun program penghancur (red=Virus) yang tidak kalah dengan VBscript.

Saya disini mencoba belajar membuat batch file menggunakan perintah dasar "echo", pertama coba anda ketikkan perintah seperti ini :

Echo belajar dan berbagi...

Perintah Echo ini berfungsi untuk menampilkan pesan, komentar atau keterangan dan lain-lain yang diberikan oleh user ketika berada dalam kondisi tertentu.

Yang kedua, anda simpan perintah tadi yang sudah diketik dengan nama Coba1.bat.

Ketiga, coba anda jalankan file Coba1.bat... jreng...jreng ada hasilnya kan??
Pasti ada dong, jendela command prompt muncul sebentar terus hilang lagi deh ya kan??

Bingung tidak bisa melihat apa isi dari command prompt tadi, nah saya akan sedikit berbagi tips nya agar jendela command prompt tadi tidak tertutup dengan cepat, caranya..

Edit file Coba1.bat yang tadi, tambahkan kata "Pause" dibawah tulisan "echo" seperti ini :

Echo belajar dan berbagi...
Pause


Kalau sudah anda simpan lagi perintah batch file tersebut dengan nama yang sama dan coba jalankan.
Terulang lagi seperti yang tadi? Tapi ada sedikit perbedaan pasti, jendela command prompt tidak langsung hilang, coba sekarang anda tekan sembarang tombol hilang.

Sekarang dapat kita ketahui bahwa perintah Pause di batch file tadi berfungsi untuk menghentikan proses sementara waktu, dan akan berjalan kembali setelah ada perintah masukan (Menekan Tombol).

Selanjutnya buat agar tampilan command prompt nya lebih berbeda, coba anda tambahkan perintah "Echo Off" tanpa tanda kutip loh seperti ini :

Echo off
Echo belajar dan berbagi...
Pause


Perlu anda ingat, tulis di file Coba1.bat yang tadi. anda simpan file Coba1.bat yang telah di edit dan jalankan.... Nah kan tampilan nya berubah lebih enak dilihat. Sekarang kita belajar membuat batch programing lebih rapih lagi, hanya dengan menambahkan perintah "CLS" pada file Coba1.bat seperti ini contohnya..

Echo off
cls
Echo belajar dan berbagi...
Pause


Selanjutnya simpan dan jalankan lagi, perhatikan perbedaan tampilan command prompt-nya

Coba ketikkan help pada command prompt, maka akan muncul teks yang membantu anda untuk belajar memahami perintah pada command prompt.

Cara mengganti pesan yang ditampilkan perintah PAUSE

Option #1:
@echo off
echo Press any key to continue or Ctrl-C to abort.
pause > null

Option #2
set /p=Press any key to continue or Ctrl-C to abort.

-->> I prefer the screen output of option #1.

Komentar

Postingan populer dari blog ini

REGEX: Regular Expressions

  Standards [ edit ] The  IEEE   POSIX  standard has three sets of compliance:  BRE  (Basic Regular Expressions), [29]   ERE  (Extended Regular Expressions), and  SRE  (Simple Regular Expressions). SRE is  deprecated , [30]  in favor of BRE, as both provide  backward compatibility . The subsection below covering the  character classes  applies to both BRE and ERE. BRE and ERE work together. ERE adds  ? ,  + , and  | , and it removes the need to escape the metacharacters  ( )  and  { } , which are  required  in BRE. Furthermore, as long as the POSIX standard syntax for regexes is adhered to, there can be, and often is, additional syntax to serve specific (yet POSIX compliant) applications. Although POSIX.2 leaves some implementation specifics undefined, BRE and ERE provide a "standard" which has since been adopted as the default syntax of many tools, where the choi...

Error when install new Instance or SSIS SQL Server 2008

Error : attributes do not match. present attributes (directory compressed) included attributes (0) Cause:  Sql server will validate the installation folder during the setup process to check if no Archive attribute as set on the installation folder The installation folder includes “C:\Program Files\Microsoft SQL Server and if you have it C:\Program Files (x86)\Microsoft SQL Server.”  Solution: - Go to SQL server installation directory - C:\Program Files\Microsoft SQL Server - C:\Program Files (x86)\Microsoft SQL Server - Right click on the folder and go to properties - Click on general tab and click on Advanced and uncheck the option “Folder is ready for archiving” - Try doing the installation again it will be successful

Difference: SQL UNION vs UNION ALL?

  Difference: SQL UNION vs UNION ALL ? UNION and UNION ALL are both used to retrieve records from multiple tables. This article will detail the differences between the two, allowing you to make the best choice for each unique scenario. You can use SQL’s  UNION  and  UNION ALL  commands to get data from multiple tables in your database. It’s a common use case, considering that most databases have many tables. Both  UNION  and  UNION ALL  are known as set operators. In SQL, set operators combine the results of two or more queries into a single result. You can  read more about set operators in this article . When comparing  UNION  vs.  UNION ALL , there is one major difference: UNION  only returns  unique UNION ALL  returns  all  records, including duplicates. If you feel like you would benefit from a well-structured, comprehensive course that covers foundational SQL, consider this  SQL...