Skip to main content

Posts

Clear Recycle Bin using command line

If the computer has multiple user account; to clear the recycle bin using command line, you need to get first the SID account of the user.
And the user account that is used to clear the recycle bin should have the proper privileges to access the recycle bin folder.
In Windows 7 and even in Windows 8, to get the user SID is quite straight forward using the command line.
Open a command prompt or press "Windows key" + "R" key to open RUN box and type "cmd" without quotes and press enter or click ok.
It will open the command prompt and type: whoami /user
From the output the user name and the SID will be displayed, copy the SID to clipboard or to notepad.
To copy from the command prompt, position the cursor from the first character where you want to start copying then right click, the select “Mark” a white box will appear drag over to the last character you want to copy and just press enter.
After pressing enter, the mark lines or selected line will be copied…

Combine photos for printing

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 the processed string
'specify…

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 Powershell to check open ports in Windows.
http://quickbytesstuff.blogspot.sg/2014/08/check-for-op…

How to lock computer after inactivity