Skip to main content

Posts

Showing posts from March, 2015

Excel VBA replace first or last character

Excel VBA code below will replace the first or last character of the cell value. Use a test workbook with dummy data, to test the VBA code. Works fine on Excel 2010. Sub replaceChar() 'Replace Last Character Dim i, ilength As Integer Dim strCellValue, yCutString, zValue As String Dim iRow, myColumn As Long 'specify the column where the values will be changed myColumn = 2 'get the last row iRow = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row For i = 1 To iRow On Error Resume Next strCellValue = Cells(i, myColumn).Value ilength = Len(strCellValue) - 1 'left - will replace last character on the string yCutString = Left(strCellValue, ilength)   ' LastChar is the string that will be added to the end of the cell value 'Replace this with any desired value zValue = yCutString + "LastChar" 'Display the value of the processed string 'press ctrl+break to stop the loop MsgBox zValue 'uncomment this line to replace the value with ...

Show interfaces via command line

Using netsh.exe will list network interfaces that are connected to the windows machine. netsh interface ipv4 show interfaces netsh interface ipv6 show interfaces If the device is connected or disconnected the command line output will show the state of the interface. But if the network interface device is disabled the interface will not be included on the output list. Sample output of the command: netsh interface ipv4 show interfaces Idx      Met          MTU           State                 Name ---   ----------   ----------   ------------   ---------------------------   1           50   4294967295   connected      Loopback Pseudo-Interface 1   12    ...

Netstat to check listening ports

To check listening ports on windows, netstat is a tool that is quite handy. And not only windows uses this tool, Linux system use this tool also. In windows to check listening ports and the application that uses the port type: netstat -abn The command needs to run at an elevated command prompt. netstat -ano   is able to check listening and established ports. Check out this link on how to open an elevated command prompt: http://quickbytesstuff.blogspot.sg/2014/10/open-elevated-command-prompt.html The command will list the local address the foreign address or the public ip and the state. Example output will be like this: [chrome.exe]  TCP    192.168.1.50:3101    0.0.117.1:443     ESTABLISHED In Linux this command would come handy: netstat -tulpn It will list the udp, tcp ports that are listening and also the daemon service listening or using the port. Check out link below how to use netstat and Power...

How to lock computer after inactivity

Lock computer automatically after inactivity or after a specified idle time. There's quite a lot of ways to lock a computer automatically, if the computer has been idle for a period of time. On a domain environment the system administrator can set via GPO. Force a screen saver to run with password after inactivity. Set the computer to sleep mode and lock the screen. Force the user to press ctrl+alt+delete and type their password. In a home computer or personal computer it can be done as well. Task Scheduler helps a lot to do things automatically; it's like set it and forget about it. A onetime setup and if it works perfectly for the first time; if there's no other issues then it will always work. Check out screen shot below on how to set a batch file or a script to run after a certain period of inactivity. The idle time on Task Scheduler can be set to X minutes of desired idle time. When the idle time is reach the batch fil...