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 li...

Combine photos for printing

Printing photos in Windows 7 on a glossy paper or photo paper with multiple photos can easily be done using the default windows photo viewer. Default photo viewer has also pre-defined sizes that can easily be selected. See image below: To set the paper size, color, the paper tray settings click on “options” which can be found on the lower right corner of the default photo viewer. How to set multiple photos in one sheet for printing? Open the folder which has the photos or pictures; to select four or more pictures click on each picture while holding the “control key” of the keyboard. Then do a right click on the mouse or press “shift key” + “f10” on the keyboard and select print. This will open the default windows photo viewer, select the desired size, click on options to set printer properties and click print. This will take time to spool especially if the photos are quite large in size. Be patient, while its being set for printing. If you...

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...

Word VBA get paper tray settings

VBA code below will get and set paper tray settings of a word document. Macro tested on Word 2010. Values 7 and 1 are the value output from the message box. I'm not sure whether values are dependent on printer driver. On my word 2010 those are the values that can be used to set paper tray settings. 7 - will set to "Automatically Select" 1 - will set to Tray1 If got documents received from other party that always retain the printer settings. A macro will be useful to change the settings or by doing it manually by going to Page Setup and change the paper tray settings. Sub getpapertray() Dim xtray1, xtray2 xtray1 = ActiveDocument.PageSetup.FirstPageTray xtray2 = ActiveDocument.PageSetup.OtherPagesTray MsgBox xtray1 MsgBox xtray2 'Set the tray to Automatically Select ActiveDocument.PageSetup.FirstPageTray = 7 'Set the tray to Tray 1 ActiveDocument.PageSetup.OtherPa...