Create A Run As Batch File

Hopefully I have got two ideas to create a batch file that will run as administrator itself without the need of another instruction or file. Both methods works differently. One method is to adding some lines of code to your bat file, where another is, converting your bat file into an executable file.

Contents • • • • • • • • • What is a Batch File No matter how fast the technology moves forward, you are always going to come back to the basics for one thing or the other. MS-DOS, for example, is the underlying niche from which everything began for Microsoft. That’s where a batch file comes into the picture. A batch file is nothing but a script file containing a sequence of commands that you store in a text file. It is something that is executed by the command line interpreter.

Enter through the command prompt (DOS). It is equivalent to what a shell script is in a UNIX based operating system. So if you want to execute a certain command you can do so directly from the command line (cmd). Let us quickly create a small batch file to open ““. An Example of a Batch File Step 1: Open notepad and type the following in it: start “” www.google.com Step 2: Save the notepad file as a batch file meaning provide the extension of the file as.bat like this: I have named it ping. You can name it anything. Step 3: After you have saved it to the desired location, open it by double-clicking it.

You will notice that it will open the URL of Google: So you get the gist of it. That you can perform any action that is possible on the windows using a batch file. You can prepare a series of commands to be executed one by one allowing a certain thing to happen using a batch file. Now if that part is clear, let’s move on to learn what we intended to learn in the first place.

You guessed right: How to create a batch file to run Testng.xml Steps on How to Create a Batch File to Run Testng.xml I am assuming that you already have a testng.xml waiting to be executed using a batch file. Here’s the directory structure that I currently have: As you can see my testng.xml file is directly located inside my project. Creation of Lib Folder Basically what we need in our batch is to specify classpath for both bin and lib folder. Since we already have bin created by default when you create a project in Eclipse, we will take care of the other one – lib. Fusa gamepad for psp. So we gotta create a lib folder and place all the required library or jar files in there. We need to provide that reference later on inside our batch.

Step 1: So I will quickly create the folder by right clicking on my project name and the selecting New > Folder: Time to rename it as “Lib”: Step 2: Click on Finish when done. Transfer all your required jar files (in this example just two) in this lib folder. To do that you need to first have the lib folder opened. Step 3: Navigate to Eclipse and right-click on the lib folder. Then Select Properties: Step 4: Then copy the location from there as shown above. Step 5: Navigate to your explorer and paste the location that was copied in Step 4 in the address bar and then press Enter: Your empty lib folder will be now open: Step 6: Locate your library jar files in your drive, select them and right-click > Copy.

Step 7: Navigate back to the lib folder and paste them there, by pressing Ctrl + V or by right clicking and selecting Paste: You can navigate back to your project folder and see we have both bin and lib in place: Looks about right. Time to foucs on the batch file now: Creating the Batch File for Testng.xml Moving on to the batch file creation part in the How to Create a Batch File to Run Testng.xml tutorial. Step 8: Open notepad by pressing windows + R and typing in notepad: Time to set your project path first. Setting up Project Path Step 9: Locate where your project folder is and copy its path and then type it in the following manner in your blank notepad file: set ProjectPath=C: Users prashant.singh03 Documents trial Your project path will be different of course. My project name here is trial. NOTE: You can look for your project location by simply right clicking on your project in Eclipse and then selecting properties as was shown in Step 3.

Related Post