بازگشت   پی سی سیتی > کامپیوتر اینترنت و شبکه Computer internet > سیستم عامل > ویندوز windows > مقالات آموزش ترفندها... Traning

مقالات آموزش ترفندها... Traning در این قسمت مقالات آموزشی ترفندها نکته ها و .... قرار دارند

پاسخ
 
ابزارهای موضوع نحوه نمایش
  #1  
قدیمی 06-01-2008
دانه کولانه آواتار ها
دانه کولانه دانه کولانه آنلاین نیست.
    مدیر کل سایت
        
کوروش نعلینی
 
تاریخ عضویت: Jun 2007
محل سکونت: کرمانشاه
نوشته ها: 12,700
سپاسها: : 1,382

7,486 سپاس در 1,899 نوشته ایشان در یکماه اخیر
دانه کولانه به Yahoo ارسال پیام
پیش فرض How to Group Multiple Commands in cmd.exe

How to Group Multiple Commands in cmd.exe
www.wisdombay.com

This article is an attempt at explaining the task of getting multiple commands executed in a sequential way in cmd.exe. This article also looks at executing groups of commands based on the status of (success or failure) of any previous commands.
First of all let's have a look at Chaining Multiple commands.

Syntax : command1 & command2
For example if you need to change the current directory to a specific directory and then list all the .mp3 files there, you can go for the below given command
کد HTML:
C:\ cd mymusic & dir *.mp3
So for chaining multiple commands it's pretty simple, just add an '&' in between the commands that you want to chain.
Conditional execution of chained commands
The below given syntaxes can help you in situations were you need to execute some chained command based on the outcome of some previous command. These come handy when you are writing Scripts or Batch files.
1. Syntax : Command1 && Command2
This makes sure that command2 is executed only if command1 is executed successfully.
Ex :
کد HTML:
dir *.bat && echo "Batch Files Found"
The above code will output 'Batch Files Found' only if the first command 'dir *.bat', executes successfully .i.e, if there are some batch files in the current directory. If first command returns no batch file then second command is not executed.
2. Syntax : Command1 || Command2
This makes sure that command2 is executed only if command1 is not executed successfully. So in this case command2 is executed only when command1 fails.
Ex :
کد HTML:
dir *.bat || copy d:\usefulbats\*.bat .
The above code will copy the batch files from d:\usefulbats to current directory only if the first command i.e 'dir *.bat' fails. So if there is no batch file in current directory it copies the batch files from d:\usefulbats to current directory
Grouping Command Chains
This section explains, how you can combine and exactly control the order in which the command chain is executed.
Ex :
کد HTML:
hostname & ver & vol > info.txt
The above example attempts to output the hostname, operating system version information and volume information to a text file called info.txt. But only the last command's output is channeled to the text file. So to archive the desired result use the following command group

کد HTML:
(hostname & ver & vol) > info.txt
Grouping can also be used with conditional chained commands also, with a syntax like. (command1 & command2) && (command3)
So i am winding up this paper on using Grouped commands in cmd.exe for now. Will catch up with you later with more technical papers like these in the future
__________________
مرا سر نهان گر شود زير سنگ -- از آن به كه نامم بر آيد به ننگ
به نام نكو گر بميــرم رواست -- مرا نام بايد كه تن مرگ راست



پاسخ با نقل قول
جای تبلیغات شما اینجا خالیست با ما تماس بگیرید




پاسخ


کاربران در حال دیدن موضوع: 1 نفر (0 عضو و 1 مهمان)
 

مجوز های ارسال و ویرایش
شما نمیتوانید موضوع جدیدی ارسال کنید
شما امکان ارسال پاسخ را ندارید
شما نمیتوانید فایل پیوست در پست خود ضمیمه کنید
شما نمیتوانید پست های خود را ویرایش کنید

BB code is فعال
شکلک ها فعال است
کد [IMG] فعال است
اچ تی ام ال غیر فعال می باشد



اکنون ساعت 02:27 AM برپایه ساعت جهانی (GMT - گرینویچ) +3.5 می باشد.



Powered by vBulletin® Version 3.8.4 Copyright , Jelsoft Enterprices مدیریت توسط کورش نعلینی
استفاده از مطالب پی سی سیتی بدون ذکر منبع هم پیگرد قانونی ندارد!! (این دیگه به انصاف خودتونه !!)
(اگر مطلبی از شما در سایت ما بدون ذکر نامتان استفاده شده مارا خبر کنید تا آنرا اصلاح کنیم)


سایت دبیرستان وابسته به دانشگاه رازی کرمانشاه: کلیک کنید




  پیدا کردن مطالب قبلی سایت توسط گوگل برای جلوگیری از ارسال تکراری آنها