Some tricks in Windows Scripting
TipsMake.com - Whether you are a person working in the IT field, such as a web designer, or an office worker, even a student, needs Windows Scripting because it will provide give you a lot of utilities. For Mac users, they can use AppleScript as the top solution, but here we will show Windows users how to use Windows Scripting in their work, and read the following article to see if it has what ability
Windows Scripting itself (WSF) is a file that includes many code and is saved as .wsf. Windows will compile and run this file directly.
Windows Scripting is actually much more powerful than batch jobs that IT professionals often write and run for years. WSF provides users with the power of a Visual Basic-like language. By default, you can create a VBScript or JScript WSF file on Windows and they all work fine.
In this article, we will introduce you to three typical tools that people often use in a professional and home IT environment. These three tools include: receiving input data from text files; ping different devices on your network; and sending email through the script is available.
The power of Windows Scripting
From the small script components you can completely combine them into a large, integrated file to perform tasks in turn with a single click. For example, after this article you can: get an IP list from the text file input, ping those devices and finally send an email notification about any device.
Receive and read the input file
The first step of this process is to learn how to read and process information from a text file input. Here we create a file called IPlist.ini (in .txt format that runs normally but we are not sure about possible problems) in the same directory as the script. The content of this file contains a list of all IP addresses that need to be checked. To be able to read each line of this text file, we use the following script:
This code uses an object in the Windows file system to open the file, then read each line at a time until the end of the file.
In case you misplaced the Iplist.ini file, the result will be displayed:
Ping to a Host
After reading the IP addresses of the incoming files, we now proceed to Ping them with Windows Scripting.
The Ping process is more complicated than reading a text file, because you need to use Windows Management Instrumentation scripting (WMI). You enter the following code:
After running the above script, a pop-up window will appear indicating whether the result of that IP is Ping or not.
In this code, we only ping Ping to a single IP address, and what you need to do is embed the Ping command after each IP address is read from the text file, so you will Ping the entire address list.
Send an Email
Finally, when you have a script to check the IP address and a pop-up window will pop up if you encounter any errors. But if you have to run these scripts on a daily basis, it will not be interesting for most users. Instead, set up so that problems are automatically sent to the email.
To do this you need to know how to send emai via script. On the Internet there are many ways to do it, the most common is using the CDO method.
The above script allows you to send any text in the body of an email to any address using the Gmail service. You can modify the parameters to use for other SMTP mail servers.
Now proceed to put the above code together. As a result, the script will read the IP address, Ping to each address and then send a message string in the body section to the email:
It is easier to automate your work in IT if you take advantage of the power of Windows Scripting. Any time these scripts will automatically check for you, especially if the system has a multitude of devices.
You should read it
- Microsoft Windows PowerShell and SQL Server 2005 SMO - Part 1
- How to Select Cells and Ranges in Excel Visual Basic
- Detecting WhatsApp flaws allows an attacker to access files on the machine
- Manage Windows networks using scripts - Part 4: Use Win32_NetworkAdapterConfiguration
- Instructions on how to use PowerShell in Windows Server 2012
- About PowerShell
- Managing Windows networks using Script - Part 11: Other script tricks
- How to send Email with Windows PowerShell
May be interested
- Detecting WhatsApp flaws allows an attacker to access files on the machinethis is a cross-site scripting (xss) vulnerability.
- The tricks in Windows 10 you may not knowthe windows 10 operating system is a great operating system, but how to handle all the productivity and features of this operating system. the following article will show you some tricks that are hidden inside windows 10 that few people know about.
- 6 Cool Tricks You Can Do in Windows Command Promptcommand prompt has a ton of capabilities, and many people doubt they know what a few lines of code can do. next time you're bored with your pc, try these cool command prompt tricks for yourself.
- Instructions on how to use PowerShell in Windows Server 2012what is powershell? windows powershell is a command-line shell language interpreter and scripting language specifically designed for system administrators. built on the .net framework, windows powershell helps it professionals control and automate windows operating system administration tasks as well as applications running on windows server environments.
- 11 harmless tricks to prank your friends and relativesthe harmless tricks below to prank your friends and relatives, make sure to bring you and your loved ones memorable moments.
- 10 tricks with Windows XPwindows xp is currently the most commonly used operating system today. windows xp is produced by microsoft for personal computers running on x86 and ia-64 processors.
- Psychological tricks that scammers often usein the heat of the moment, you are vulnerable to manipulation and if you accidentally associate with a scammer, you will likely experience one or more of the psychological tricks the scammer uses to catch you off guard.
- 9 iPhone tricks you may not know9 iphone tricks that many long-time users are not sure to understand to help you become more streamlined while using the device
- Discover the secret of handcuff magic tricks locked in closed containersthe classic magic escape from the sealed box is sinking in the river while limbs are tied by chains and cuffs always attract interest, curious to decode the audience. what secret lies behind this spectacular escape?
- Manage Windows networks using scripts - Part 4: Use Win32_NetworkAdapterConfigurationin the first two parts of this series we looked at some of the basic concepts of windows scripting technology in managing tcp / ip network settings. to illustrate and practice, we have developed a simple script with the function of changing the address of a network adapter. in today's lesson, the code line we will be training howl