How to Create an Interactive Batch Program

Documents on windows with the record augmentation ".bat" are called clump records. These are typically little records with a few lines of Windows clump code that can help robotize things for clients. They are normally used to do the accompanying:

Include an offer drive

Include an offer printer

Supplant alternate way records on your desktop

They can be utilized to do the vast majority of the basic undertakings we do on a windows machine. They are normally added to a clients logon profile with the goal that they are run each time that client sign into Windows. They can likewise be utilized as intelligent projects to do the previously mentioned things. Suppose you needed to give a client the choice of WHICH share drive he/she needed to outline. A typical bunch content will simply delineate predefined share drive. All things considered, I will demonstrate to you industry standards to compose a cluster content to ask the client which drive to guide and after that guide it for them.

How about we go over a couple of things so we recognize what each summon does.

@echo - this yields content to the clients screen

So '@echo Print this' would bring about the client screen showing 'Print this'

'@echo.' with a period after it will print out a clear line after your content. This regards make the yield simpler to peruse.

@set is utilized to set a variable. A variable that we can set and allocate in light of client input.

'@set VARIABLEA=' will set a variable named VARIABLEA and will set it to invalid (an unfilled esteem)

Presently here is the manner by which we set an incentive to that factor in light of what the client sorts in.

'@set/P VARIABLEA=TYPE IN A NUMBER. I.E. 1:%=%'

The above line will request that a client TYPE IN A NUMBER. The client will enter in a number and hit the enter key. At that point VARIABLEA will have the esteem the client entered.

To yield the incentive in that factor to the screen we will do this:

'@echo %VARIABLEA%'

Another two accommodating summons to learn are delay and reverberate off/on.

'@pause' will delay the screen and request that the client hit a key to proceed

'@echo off' will keep the framework from yielding framework messages

'@echo on' will walk out on framework messages

So how about we now set this in motion. How about we make a straightforward intelligent group content that asks a client which share drive they might want to guide and after that guide it for them. So as to do this, we should know the windows order to delineate system drive. For whatever length of time that you can execute these charges in dos then we regard utilize them. Here is the sentence structure to delineate system drive:

net utilize {drive letter}: \\{path to drive}/PERSISTENT:YES

The steady alternative will instruct it to delineate drive with the choice to consequently outline each time the client sign on. Commonly we will need to utilize this choice. So we should utilize the above code to make our content. When you are done, it will look something like beneath. Make sure to reorder this inside a content record, spare as .bat and after that you will have the capacity to double tap it to run.

Appreciate!

DRIVE MAPPER v1.0

@echo MAP YOUR DRIVE

@echo.

@echo - SELECT A SHARE DRIVE -

@echo 1.) MOVIES FOLDER

@echo 2.) PHOTOS FOLDER

@echo 3.) MUSIC FOLDER

@echo.

@set DRIVE=

@set/P DRIVE=ENTER THE NUMBER THAT YOU WANT TO MAP. I.E. 1:%=%

@ECHO.

@set DRIVE=

@set/P DRIVELETTER=ENTER THE DRIVE LETTER YOU WANT TO USE. I.E....F:%=%

@echo.

@echo.

@echo YOUR SHARE DRIVE WILL BE MAPPED TO LETTER: %DRIVELETTER%

@pause

@echo off

In the event that (%DRIVE%)==(1) net utilize %DRIVELETTER%: \\192.168.1.4\movies/PERSISTENT:YES

On the off chance that (%DRIVE%)==(1) net utilize %DRIVELETTER%: \\192.168.1.4\photos/PERSISTENT:YES

On the off chance that (%DRIVE%)==(1) net utilize %DRIVELETTER%: \\192.168.1.4\music/PERSISTENT:YES

@echo on

@echo.

@echo IF YOU DON'T SEE ANY ERRORS ABOVE, YOUR DRIVES HAVE NOW BEEN MAPPED. On the off chance that YOU SEE ERRORS ABOVE, PLEASE RERUN THIS UTILITY AND MAKE CHANGES. MOST ISSUES ARE BECAUSE YOU SELECTED A DRIVER LETTER IN USE OR YOU DIDN'T SELECT A CORRECT NUMBER FROM THE LIST ABOVE.

Comments

Post a Comment

Popular posts from this blog

Earn Income From Home With An Online Business

Facebook Marketing Strategy

The Top 3 Email Programs for Busy Entrepreneurs