[VB.NET] Parsing submenu in ToolStripMenuItem


Description
     Before parsing submenu in ToolStripMenuItem what you must know is how deep your submenu. after that you can do parsing subMenu to all menu and add some action or etc. very usefull if you implement privilege every user to access the menu.

HowTo
1. Find how deep you subMenu

File (MainMenu)
|
Manage(SubMenu 1) ==> User(SubSubMenu2) | Change Password (SubSubMenu2)
--------
Exit

based on information above we can tell the deep is 2.

2. Create 3 Variable based on the depth
    Dim mainmenu As ToolStripMenuItem
    Dim submenudepth1 As ToolStripMenuItem
    Dim submenudepth2 As ToolStripMenuItem

to parsing every submenu use this code :
For Each mainmenu In frmMain.MenuStrip.Items.OfType(Of ToolStripMenuItem)()
        For Each submenudepth1 In mainmenu.DropDownItems.OfType(Of ToolStripMenuItem)()
               For Each submenudepth2 In submenudepth1.DropDownItems.OfType(Of ToolStripMenuItem)()
                     'Do Something !! for example get name of an item menu or etc    
               Next
        Next
Next

hope this help u :D

[Windows] Date and Time in Command Prompt


Description
      File name is very important for information especially when backup files on server to storage in windows environment. we can use some command to add some date and time to filename.

HowTo


echo "Display Current Date and Time Now !!"

ECHO "YEAR :" %date:~-4%
ECHO "DATE :" %date:~4,2%
ECHO "DAY :" %date:~7,2%
ECHO "HOUR :" %time:~0,2%
ECHO "MINUTE :" %time:~3,2%
ECHO "SECOND :" %time:~6,2%

for example :

REN D:\name.log D:\name_%date:~-4%%date:~4,2%%date:~7,2%.log

The result  : name.log => name_20150712.log


you can combine this command with xcopy to get file from other server and add date or time as you like.


hope's this helps :D