Monday, January 12, 2009

Remove the New option from the explorer context menu

To remove the New option: In the registry editor navigate to: [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shellex\ContextMenuHandlers\New]

In the right column you'll find a REG_SZ value named (Default) whose data equals: {D969A300-E7FF-11d0-A93B-00A0C90F2719} Delete this (Default) value. That's it.

Now right click on the desktop and check if the menu has an entry named 'New'.

To restore the New option import the following in the registry: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shellex\ContextMenuHandlers\New] @="{D969A300-E7FF-11d0-A93B-00A0C90F2719}"

Remove access to Folder Options...

To remove access to the Folder Options in explorer import the following into the registry:

Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{BE399983-1586-4348-BDDA-08DCCADB3A6B}User\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer] "NoFolderOptions"=dword:00000001

Log Off to apply the settings. To restore the folder options Change the dword value to 00000000

Disable the Command Prompt

To disable access to the command prompt import the following into the windows registry:

Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System] "DisableCMD"=dword:00000001

Now if the user tries to open the command prompt he will get a notification stating: "The command prompt has been disabled by your administrator".

To re-enable access to the command prompt use the following: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System] "DisableCMD"=dword:00000000

Sunday, January 11, 2009

Change the Internet Explorer title text

Open notepad and paste the following and save it with a '.reg' extension

Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main] "Window Title"="Hello punkisnail"

Use your own text instead of Hello punkisnail. Import the file into the windows registry and check it out.

Detecting Arrow keys on a windows form application using VB.NET

Handling arrow keys on a VB windows form is a pain until you find a solution that works according to your needs:) Well I posted this coz I got excited having solved a problem I had with detecting the arrow keys in VB.NET. I've been struggling to detect the arrow keys on a windows application form that I was designing in VB 2008.

The form contained a TabControl and needed to detect the keys only on TabPage1. Since there were many other controls on the form I had to use an overriding function.

i.e:

Protected Overrides Function ProcessCmdKey(ByRef msg As Message, _ ByVal keyData As Keys) As Boolean

 ' detect which key is pressed and perform some action

End Function

The problem is that TabPage2 contained a textbox and would allow me to enter only a single character. To continue typing into the textbox I needed to click in the textbox and type the next character. To overcome this problem I needed to check which TabPage had the focus. But the problem was where to check the focus.

Download my code to find out how I solved my problem: http://www.mediafire.com/?wnw3zduymtj Hopefully someone finds this post useful.

Configure Hidden options through the registry

To disable changing the hidden files and folder settings in Folder Options:

Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL] "CheckedValue"=dword:00000000

To disable showing hidden files and folders:

Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] "Hidden"=dword:00000000

To disable showing superhidden files and folders:

Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] "ShowSuperHidden"=dword:00000000

To enable changing the hidden files and folder settings in Folder Options:

Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL] "CheckedValue"=dword:00000001

To enable showing hidden files and folders:

Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] "Hidden"=dword:00000001 To enable showing superhidden files and folders: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] "ShowSuperHidden"=dword:00000001

Saturday, January 10, 2009

Edit the registry using Powershell

If you use the Get-PSDrive cmdlet you'll notice that HKCU and HKLM appear as drives. This allows us to use item cmdlets to manage items in the HKLM: and HKCU: drives.

To change your location to the HKCU: drive use either Set-Location HKCU: or cd HKCU:

To navigate through the registry drive: you can use cd the same way you would use it to navigate through directories in the command prompt. You can also use Set-Location

Example to navigate to HKCU/Control Panel/Desktop
PS HKCU:\> Set-Location "HKCU:/control panel/desktop"

or

PS HKCU:\> cd "HKCU:/control panel/desktop"

To view subkeys: Use either dir or Get-ChildItem

To create a new registry key:
To create a new registry key within a subkey we can use the New-Item cmdlet
For example, to create a key named PUNKISNAIL under hkcu/control panel/desktop
PS HKCU:\control panel\desktop> New-Item PUNKISNAIL

To delete a registry key:
Here we can use the remove-item cmdlet.
For example to delete the key PUNKISNAIL which we created under hkcu/control panel/desktop use:
PS HKCU:\control panel\desktop> remove-item PUNKISNAIL

If you're in a different drive you can use the following to delete the key:
PS C:\>remove-item -path "hkcu:/control panel/desktop/punkisnail"

To get the registry entries in a key:
Here we can use the Get-ItemProperty cmdlet.

To get the properties for menushowdelay found in HKCU/Control Panel/Desktop use: Get-ItemProperty -path "hkcu:/control panel/desktop" -name menushowdelay

To create a registry entry use:
new-itemproperty -path somepath -name someEntryName -value AnyValue -propertyType SomeType Example: new-itemproperty -path "HKCU:/control panel/desktop/punkisnail" -name MyNameIs -value "Shane Lobo" -propertyType string

possible property types are: String, ExpandString, Binary, DWord, MultiString, QWord, Unknown

To clear the value of a registry entry use:
Clear-ItemProperty Clear-ItemProperty -path SomePath -name SomeEntryName

To delete a registry entry use:
remove-ItemProperty remove-ItemProperty -path SomePath -name SomeEntryName

Killing processes using the command prompt

To kill a process in the command prompt we need to know either its Image Name or Process ID. One way to find this is in the Windows Task Manager. The other way is to use the Tasklist command in the command prompt.

Command to kill a process in Windows XP Pro:

 taskkill [/pid processID | /im ImageName]} [/f] [/t]

/pid processID Specifies the process ID of the process to be terminated.

/im ImageName Specifies the image name of the process to be terminated.

Use the wildcard character (*) to specify all image names.

/f Specifies that processes be forcefully terminated.

/t Terminates the specified process and any child processes started by it.

Example: taskkill /im notepad.exe

Command to kill a process in Windows XP Home Edition: Windows XP Home Edition users can use the tskill command as follows: tskill {processID | processName}

Example: tskill notepad

Edit the registry using the command prompt

To know the contents of a particular registry key or a particular value:

REG QUERY KeyName [/v ValueName | /ve] [/s]

/v Specifies the registry value name that is to be queried.

/ve Runs a query for value names that are empty.

/s Specifies to query all subkeys and value names recursively. Example to query the value of menushowdelay at HKCU/control panel/desktop

reg query "hkcu/control panel/desktop" /v menushowdelay

To add new registry keys:

REG ADD KeyName [/v ValueName | /ve][/t Type][/d Data] [/f]

/t Specifies the type for the registry entry which must be one of the following: REG_SZ REG_MULTI_SZ REG_DWORD_BIG_ENDIAN REG_DWORD REG_BINARY REG_DWORD_LITTLE_ENDIAN REG_LINK REG_FULL_RESOURCE_DESCRIPTOR REG_EXPAND_SZ

/d Specifies the data for the new registry entry.

/f Adds the registry entry without prompting for confirmation.

Example to change the value of menushowdelay to 0:
reg add "hkcu/control panel/desktop" /v menushowdelay /t REG_SZ /d 0

To delete registry keys:

REG DELETE KeyName [/v ValueName | /ve | /va] [/f]

/va Deletes all entries under the specified subkey. Subkeys under the specified subkey are not deleted.

to export and import registry keys:

To export: REG EXPORT KeyName FileName

To import: REG IMPORT FileName

Manage services using windows powershell

To get a list of objects representing the services and their running status:
type: get-service
To get the status of a particular service, type: get-service -name servicename
where, servicename is the short name for the service.
To get the status for a service using its display name, type:
get-service -displayName
"displayname"
example: get-service -name wuauserv
get-service -displayName "Automatic Updates"
both the examples will give the same result.


To start, stop, pause and resume services:
To start a service using short names , type: start-service -name servicename
To start a service using display names, type: start-service -displayName "displayname"

To stop a service using short names , type: stop-service -name servicename
To stop a service using display names, type: stop-service -displayName "displayname"

To pause a service using short names , type: suspend-service -name servicename
To pause a service using display names, type: suspend-service -displayName "displayname"


To resume a service using short names , type:resume-service -name servicename
To resume a service using display names, type: resume-service -displayName "displayname"

To restart a service using short names , type: restart-service -name servicename
To restart a service using display names, type: restart-service -displayName "displayname"


To set how a service starts up:
set-service -name servicename -startupType {<automatic>|<manual>|<disabled>}
or
set-service -displayName displayname -startupType {<automatic>|<manual>|<disabled>}

Example: set-service -name wuauserv -startupType manual