Skip to main content

Posts

Showing posts from October, 2021

Close all open notepad instances or processes in one go

If you’re an admin and manually checking logs for details and opening each file one by one. Then opening multiple instances of notepad is quite an everyday task. Or you just love notepad in making notes, documentations or other endless reasons to use notepad. Then it will be a headache in closing all the notepad instances that were opened. However, PowerShell can be used to close all instances of notepad all at once. No sweat in clicking each file one by one. PowerShell can handle it in one click of a button if you open the file via PowerShell ISE. Here’s a simple PowerShell code snippet to close all files in one shot. #========== $x = ( Get-Process | Where-Object   { $_ . ProcessName -EQ 'Notepad' }) . count   1 .. $x | % {    stop-process -name notepad –force } #=========== Yes, 2 lines of code can save you a lot of time. The above code can be used also to close other processes that has multiple instances open on the system. If unsure of what

Ping sweep with Bash script in Linux

Ping is a good tool to easily check or troubleshoot a system whether it is online or not. Provided the system or device is allowed to reply to any ICMP request. A simple Bash script below shows how to ping a Class C subnet. Replace the IP Address range below if you want to use it depending on the IP Address set on your network. It also illustrates how to make use of while loop, increment a variable counter, and use a variable to substitute as part of the whole command in Bash.  #====================== #!/bin/sh i=0 while [ $i -ne 255 ]   # initialize the counter don't exit until 255 counter is reached do         i=$(($i+1))   #increment the variable counter by adding 1 to it         echo "$i"     # just show the counter as it is incremented         ping -c2 192.168.0.$i   # ping the IP Address twice $i will be substituted with the current number in the loop done # ======================= That's it, it will ping the IP Address twice. If the

Excel VBA find last row with data

In Excel, ctrl + end will go to the last cell with a value. But this will be tricky if you have deleted the last row with a value or has deleted its contents on the cell. Since it will be recoded as the last cell that has a value or the user has inputted or type on that specific cell.   And Excel will still remember it as the last type cell with value. Pressing ctrl + end will still go there, thus provide the wrong result. However, to prevent this from happening you need to close the workbook and open it again. Then pressing ctrl + end will show the last row with value. But while the worksheet is active any last typed cell even though its content or deleted will be considered as the last row. Getting the last row with data even without closing the workbook can be done via this simple VBA code below. One caveat though, this will only search for the defined row within the VBA code and the number of rows to be checked has to be defined on the code also. So, type a number that is