Showing posts with label change registry setting. Show all posts
Showing posts with label change registry setting. Show all posts

Sunday, May 08, 2011

Notes Windows


NotesWindows  - Notes on Windows
=============

This includes NotesWinXP which is now made obsolete.
The content here is related to any version of Windows and will be specifically denoted.


Contents
=========
Roaming Profile - Encryption
Useful Registry Keys
Stop accidentally moving files or folders
Windows Update does not work anymore
Windows CMD commands
Application Location
MS Windows XP backup
Change Location of My Pictures, My Documents
Change Location of Libraries in Windows 7
Password Revealed on Windows
Known Folders can be Hidden - Windows 7
Boot Manager - Windows XP, Windows 7
How to Repair a Corrupt Windows 7 Installation
Windows Recovery Console Operations
Windows 7 Administrator account


Roaming Profile - Encryption - WinXP
=============================
Problem: When roaming profile cannot be saved - the reason could be due to some files are being encrypted.

Solution: Find and remove the encrypted file. Use the tool "cipher" provided by WinXP.

    cipher /S:directoryName
... to check encryption status of all subdirectories

Ref:
Roaming decrypt
http://www.microsoft.com/technet/prodtechnol/winxppro/reskit/c18621675.mspx

Search windows "roaming profile" decrypt
http://au.alpha.yahoo.com/search/web?p=windows+%22roaming+profile%22+decrypt
search http://au.alpha.yahoo.com/search/web?p=windows+%22roaming+profile%22+decrypt


 

Useful Registry Keys
================================
Append Path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
System Path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
User path:   HKEY_CURRENT_USER\Environment
Reserved Drives Letters: HKEY_LOCAL_MACHINE\SYSTEM\MOUNTEDDevices

Stop accidentally moving files or folders  - WinXP
===========================================
It is very easy to accidentally move folders in Windows Explorer, simply by careless movement of the mouse and accidentally releasing buttons. This problem is also very easy to occur with trackpads on laptops. There is a way of preventing this accidental motion by making Windows pop up a dialog box to ask for confirmation.

"Do You Want To Move Or Copy Files From This Zone?"

To enable this feature,
1. Click Start -> Control Panel -> Internet Options.
2. Click “Security” tab, mark the zone “Local intranet”, and click the “Sites” button.
3. Un-tick “Automatically detect intranet network”
4. Tick “Include all local (intranet) sites not listed in other zones”
   Tick “Include all sites that bypass the proxy server”
   Untick “Include all network paths (UNCs)”  

Windows Update does not work anymore  - WinXP
=====================================
For some reason, Windows files may corrupt such that the Windows Update will not work anymore. To solve this:
1. Open a Command Prompt Terminal: Start - Run, type: cmd.
2. To stop the current windows update service, in the Command Prompt, type:
    net stop wuauserv
3. Re-register the windows update dll for WinXP 32bit
    regsvr32 %windir%\system32\wups2.dll
Re-register the windows update dll for WinXP 64bit
    regsvr32 %windir%\syswow64\wups2.dll


Windows CMD commands
=====================
Ref: http://ss64.com/nt/

When in a CMD terminal, to launch another CMD terminal and execute a script (test.bat)
- start cmd /k test.bat    - new window remains open
- start cmd /c test.bat    - closes the new window when script finishes

Some commands related to Volume Shadow Copy Service (Vista)
vssadmin List Shadows
vssadmin List ShadowStorage


Application Location
=====================
WinXP:
Netscape Bookmarks (Netscape v 8.1)
D:\Program Files\Netscape\Netscape Browser\defaults\profile\bookmarks.html


MS Windows XP backup
======================
Below describes the process to take when backing up Windows. Some folder directory sizes given here may give an indication of their relative or typical sizes, but they will obviously vary in different systems.

- Login as each user and i) Empty Recycle Bin, ii) Clear all Cache, Cookies
- Login in as Administrator (so that can backup Registry and other System State)
- Goto Control Panel - Performance and Maintenance - "Free up space in your hard disk"
- c:\windows\system32 = 1GB
- c:\windows\ folders except system32 = 790MB
- c:\windows\system32\dllcache = 467MB
- c:\windows\$NTUninstall* = 245MB
- c:\windows\Driver Cache = 87MB
- c:\windows\fonts = 89MB
- c:\windows\help = 46MB
- c:\windows\ime = 86MB
- To backup Registry - go to the GUI windows Backup Utility and check the "System State"
- Do Normal and then Incremental backup.


Change Location of My Documents
=================================
WinXP:
Change My Documents.
- Right click My Documents - Properties - change the Target Location
- by default My Documents is in C:\Documents and Settings\<user>\My Documents

My Pictures, My Music.
- It appears that these folders are not changeable and are set under My Documents.
- When My Documents location is changed, then these folders should follow too.


Change Location of Libraries in Windows 7
===========================================
Libraries in Windows 7 can be assigned to various locations. Libraries will source the physial location of target directories and present the contents as if they all belong to the library. To change the location of Libraries in Windows 7:
- open Explorer
- in the left hand pane, right click on the library icons
- select Properties
- a list of location is presented, which can then be modified


Password Revealed on Windows
==============================
Windows 7:
- Passwords apparently can be revealed by System Information for Windows.
- the System Information (Start - All Programs - Accessories - System Tools - System Information) on Windows XP do not seem to reveal passwords.
- to remove the passwords in Windows 7, do:
    Control Panel - User Accounts and Family Safety - Windows Credential Manager.



Known Folders can be Hidden - Windows 7
==========================================
Windows default folders like Music, Pictures, Videos, Searches are part of the operating system and is not easy to remove. They may be hidden in a number of different ways.
1. Move them to another location by:
- Right click and select properties of the Known Folder
- Go to Location tab
- use the button Move to specify new location.
2. Merge them into Documents folder.
- Select the Known Folder to move.
- For the target to move to, select Documents.
3. Remove Known Folders
- Go to Start button and type, GPEDIT.MSC
- Under User Configuration, click Administrative Templates, double click Windows Components, then Windows Explorer.
- In the Disable Known Folders setting, double click and select Enabled.
- Click Show and enter names of any folders to be disabled.
- Go back to main Windows Explorer and delete any of the Known Folders, and it will be permanenet.

For a list of Known Folders, http://msdn.microsoft.com/en-us/library/bb882665.aspx


Boot Manager - Windows XP, Windows 7
======================================
Boot Loader for Windows XP: NTLDR
Sits on the Primary Partition of the Hard Disk
Configuration file: boot.ini
To edit, use Notepad

Boot Loader for Windows 7 / Vista : Windows Boot Manager (BOOTMGR)
Sits on the Primary Partition of the Hard Disk
Configuration file: BCD (Boot Configuration Data)
To edit, use BCDEDIT


How to Repair a Corrupt Windows 7 Installation
================================================
http://www.computerworld.com/s/article/9221540/How_to_Repair_a_Corrupt_Windows_7_Installation?taxonomyId=89&pageNumber=3


Windows Recovery Console Operations
====================================
Firstly to enter into recovery console, by booting from Windows CD/DVD. When 'Welcome to Setup' appears, then press 'R'. Here is a list of commands that may be helpful for repairing or trouble shooting in Recovery Console mode.

listsvc        - list the services running. Example display drivers agp440.sys is listed
disable agp440 - to disable a service that is running and listed under listsvc.


Windows 7 Administrator account
==================================
This section is specifically for Windows 7. In previous versions of Windows, there may appear the Administrator user on the login page. The Administrator account does not appear on Windows 7 by default.

By default, the Windows 7 installation usually
- allow you to create a new user, say FirstUser, during install and will set it up with Administrator password.
- there is a hidden Administrator user, but it is not active and has no password.

To manage the Administrator account, eg to activate it or give it a password, etc:
- click Start
- right click Computer - Manage
- Go to System Tools - Local User and Groups - User
- perform any task including Administrator account.

Alternative way to make Administrator appear on login screen.
- click Start and in the Search box, type CMD
- right click on the CMD icon that appears, choose Run As Administrator
- in the Command Prompt type:
  net user administrator /active:yes
      or
  net user administrator /active:no





Thursday, May 14, 2009

techNote_Append Registry Via Visual Studio Setup Project


How can I append a directory to the PATH environment variable when creating a Visual Studio Setup project.


Objective: To be able to APPEND Path Environment Variable by changing Windows Registry setting,  using a MSI Windows Installer created by a Visual Studio Setup project.

End Product: An exe and a msi file to install a program and also change registry setting automatically. When the program is uninstalled (via Add or Remove programs) then the registry setting will be changed to the pre-installation state.

Reference: This article is based on the article and code found below, but with necessary modifications.
http://askville.amazon.com/append-directory-PATH-environment-variable-Visual-Studio-Deployment-installation-Project/AnswerViewer.do?requestId=4628663

The code presented in askville, assumes that the path to be added is only the path where the programs are installed. For example if pre-install path = "c:\temp", and the program is to be installed in "c:\programs", then the final path would be "c:\temp;c:\programs".

With the modifications I made to the code, it allows the user to setup multiple additional paths, not only where the program is installed. The scenario is like this:
Preinstall path variable: c:\temp
Additional paths: c:\dirA;c:\dirB
Installation path: c:\programs
Intended final path: c:\temp;c:\dirA;c:\dirB;c:\programs
After uninstall path: c:\temp

Basically, the idea is to create a custom action class and then configure the Setup project.
Here are the detailed steps of how to construct the Visual Studio setup project.

1. Copy the code below and put into an empty C# class and called in Installer1.cs. Need to change the Namespace in the code to tailor to the namespace of your project.

Basically, the C# code override the Install, Uninstall, and Rollback methods of the standard Installer class.

2. The C# class file in step 1 need to be put into a C# project. It could be a new project or it could one of your working project to be included in the Setup Project.

3. Create the Visual Studio Setup Project. Add the C# project in step 2 to the setup. This is done in the normal way by right clicking the setup project in Solution Explorer. Click Add -> Project Output. Then select that C# project and select Primary Output, then click OK.

4. Right click on your Setup project, select View|Custom Actions, and then right-click on Install, Rollback, and Uninstall to add the assembly containing the custom action class to each one.

5. Finally add any additional directories to the user path via the Registry by the following:
i) Assume that the new variable to be appended to the User Path is called "MySetup". This name "MySetup"
is hard coded to the function GetAddedPath, which can be changed as desired.
ii) Right click on the setup project, choose View -> Registry.
iii) In the Registry editor, go to HKEY_CURRENT_USER and add new Key "Environment" if it is not there already.
iv) Click on the new "Environment" entry and ADD -> New -> Environment String Value.
v) on the right hand pane, name the new variable as "MySetup".
vi) Click on the entry "MySetup" and in its property box, write the value of any subdirectories you wish to
include in the user path.
---------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using Microsoft.Win32;

namespace YOUR_OWN_NAMESPACE
{
    /// <summary>
    /// A Custom Action class that provides action to append registry for MS Setup project.
    /// </summary>
    [RunInstaller(true)]
    public partial class Installer1 : Installer
    {
        public Installer1()
        {
            InitializeComponent();
        }

        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);
            string curPath = GetUserPath();
            stateSaver.Add("previousPath", curPath);
            string newPath;
            if (curPath.Length == 0 ) {
                newPath = AddPath(GetAddedPath() , MyPath());
            }else{
                newPath = AddPath(curPath, GetAddedPath()+";"+MyPath());
            }
           
            if (curPath != newPath)
            {
                stateSaver.Add("changedPath", true);
                SetPath(newPath);
            }
            else
                stateSaver.Add("changedPath", false);
        }

        public override void Uninstall(System.Collections.IDictionary savedState)
        {
            base.Uninstall(savedState);
            if ((bool)savedState["changedPath"])
            {
                SetPath(RemovePath(GetUserPath(), MyPath()));
                SetPath(RemovePath(GetUserPath(), GetAddedPath()));
            }
        }

        public override void Rollback(System.Collections.IDictionary savedState)
        {
            base.Rollback(savedState);
            if ((bool)savedState["changedPath"])
                SetPath((string)savedState["previousPath"]);
        }

        internal static string MyPath()
        {
            string myFile = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string myPath = System.IO.Path.GetDirectoryName(myFile);
            return myPath;
        }

        private static RegistryKey GetPathRegKey(bool writable)
        {
            // for the user-specific path...
            return Registry.CurrentUser.OpenSubKey("Environment", writable);

            // for the system-wide path...
            //return Registry.LocalMachine.OpenSubKey(
            //    @"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", writable);
        }

        private static void SetPath(string value)
        {
            using (RegistryKey reg = GetPathRegKey(true))
            {
                reg.SetValue("Path", value, RegistryValueKind.ExpandString);
            }
        }

        internal static string GetUserPath()
        {
            using (RegistryKey reg = GetPathRegKey(false))
            {
                return (string)reg.GetValue("Path", "", RegistryValueOptions.DoNotExpandEnvironmentNames);
            }
        }
        internal static string GetAddedPath()
        {
            using (RegistryKey reg = GetPathRegKey(false))
            {
                return (string)reg.GetValue("MySetup", "", RegistryValueOptions.DoNotExpandEnvironmentNames);
            }
        }


        private static string AddPath(string list, string item)
        {
            List<string> paths = new List<string>(list.Split(';'));

            foreach (string path in paths)
                if (string.Compare(path, item, true) == 0)
                {
                    // already present
                    return list;
                }

            paths.Add(item);
            return string.Join(";", paths.ToArray());
        }

        private static string RemovePath(string list, string item)
        {
            List<string> paths = new List<string>(list.Split(';'));

            for (int i = 0; i < paths.Count; i++)
                if (string.Compare(paths[i], item, true) == 0)
                {
                    paths.RemoveAt(i);
                    return string.Join(";", paths.ToArray());
                }

            // not present
            return list;
        }

    }
}


Tuesday, January 31, 2006

NotesWinXP

NotesWinXP  - OBSOLETE -> See NotesWindows

Roaming Profile - Encryption
Environment Path in Registry
Stop accidentally moving files or folders
Windows Update does not work anymore


Roaming Profile - Encryption
=============================
Problem: When roaming profile cannot be saved - the reason could be due to some files are being encrypted.

Solution: Find and remove the encrypted file. Use the tool "cipher" provided by WinXP.

    cipher /S:directoryName
... to check encryption status of all subdirectories

Ref:
Roaming decrypt
http://www.microsoft.com/technet/prodtechnol/winxppro/reskit/c18621675.mspx

Search windows "roaming profile" decrypt
http://au.alpha.yahoo.com/search/web?p=windows+%22roaming+profile%22+decrypt
search http://au.alpha.yahoo.com/search/web?p=windows+%22roaming+profile%22+decrypt


 

Environment Path in Registry
================================
Append Path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
System Path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
User path:   HKEY_CURRENT_USER\Environment


Stop accidentally moving files or folders
===========================================
It is very easy to accidentally move folders in Windows Explorer, simply by careless movement of the mouse and accidentally releasing buttons. This problem is also very easy to occur with trackpads on laptops. There is a way of preventing this accidental motion by making Windows pop up a dialog box to ask for confirmation.

"Do You Want To Move Or Copy Files From This Zone?"

To enable this feature,
1. Click Start -> Control Panel -> Internet Options.
2. Click “Security” tab, mark the zone “Local intranet”, and click the “Sites” button.
3. Un-tick “Automatically detect intranet network”
4. Tick “Include all local (intranet) sites not listed in other zones”
   Tick “Include all sites that bypass the proxy server”
   Untick “Include all network paths (UNCs)”

Windows Update does not work anymore
=====================================
For some reason, Windows files may corrupt such that the Windows Update will not work anymore. To solve this:
1. Open a Command Prompt Terminal: Start - Run, type: cmd.
2. To stop the current windows update service, in the Command Prompt, type:
    net stop wuauserv
3. Re-register the windows update dll for WinXP 32bit
    regsvr32 %windir%\system32\wups2.dll
Re-register the windows update dll for WinXP 64bit
    regsvr32 %windir%\syswow64\wups2.dll