DOS - NT - Windows Tips

Just some notes  

These are my personal notes that I use as a quick help in my work.
You are welcome to read them.

Contents of current page Top-level home page
 
Index  Java Internet Oracle Notes
Linux Basics Web Basics SQL Notes
Informatica Servlets Apache BkpRstore SQL*Plus
Teradata   LDAP Storage PL/SQL
Windows     Tables OEM
UML   Net8 Portal
SQL Server Python perl Performance OLAP
Vmware Visual Basic PHP/MySQL User Mgmt  
Git        
More technical pages here

Contents

 


Introduction

 

 


Basics

 

Sleep --> stores the information in RAM. This means that if power is completely turned off, unsaved data is lost.
Hibernate --> saves the contents of memory into a physical file called hiberfil.sys on disk.
In both cases, save all work to disk

 

Shortcut Keys

Windows

[W] + m Minimize all windows
[W] + M Maximize all windows
[W] + e Windows explorer
[W] + r "Run" dialog box
[W] + f Search for files
[W] + ^f Search for computers
[W] + [pause] System properties
[W] + v Show clipboard history

Other characters: see chars.html
Special character keys for MS-office: see Section on MS-Office

The location of "send-to" in Windows 7: C:\Users\{username}\AppData\Roaming\Microsoft\Windows\SendTo

 

Links on taskbar:
To make this show, right-click on task bar and choose "toolbars". Enable "links"

 

 


Hardware and Windows

 

Fault tolerance:

IDE / ATA

SCSI

FAT / NTFS

 

Add new scsi drive: plug in, at startup: verify that the new disk is recognized. W2000: in computer management / disk management : should see the new disk. Right click to format.

Installing new driver to replace a previous driver: information about the old driver prevents the new driver from being installed. This information is kept in C:\WINNT\inf. Move the file and start again.

Drivers *.sys may be in system32\drivers.

Windows Management Instrumentation Command-line (wmic)

 


Backup and Restore Issues

Sytem Restore: all program > accessories > system tgools > system restore

Backup and restore registry: see Registry below

Recovery console: see operating system below

 

Windows XP System Restore

When cleaning viruses, the System Resore should be disabled.

To turn off:

To turn on, go to the same place and remove the check in the "Turn off System Restore" or "Turn off System Restore on all drives" check box.

 

Tips for backup

 

 

 


Registry

regedit /

See service or driver startup options:
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet00n\Services\<name of driver or service><name of suspected service>
    Boot 0x0 (only drivers)
    System 0x1 (only drivers)
    Automatic 0X2
    Manual 0x3
    Disabled 0x4
<-- try setting to disabled if the driver or service is creating a problem
Which control set?:
HKEY_LOCAL_MACHINE\System\select\current = n --> controlSet00n
HKEY_LOCAL_MACHINE\System\select\default
HKEY_LOCAL_MACHINE\System\select\lastKnownGood

 

Change the maximum registry size (RSL setting): Control Panel > System > Advanced tab. > Performance Options, > Change (Virtual Memory section). Then reboot. Note that the only time that I had this error, the system registry file had increased from 3MB to 146MB. So, I restored an old copy instead.

 

Backup and restore registry files

The registry is backed up with the ntbackup utility when the appropriate box is checked. The copies go into windows\repair\RegBack.

Restore the 5 registry files (default, sam, security, software and system):

 


Windows Operating System

Performance:

Audit failure of logon/logoff and audit success and failure of security policy changes.

For system information: start > programs > accessories > system information.

For performance: configuration panel > system properties > tab "advanced" > button "settings" in performance

 

Troubleshooting Startup

Press F8 during startup ("Starting Windows" at bottom of screen):

Also:

msconfig startup tab: programs that are loaded on startup

 

Interpreting the Task Manager Figures

Totals:

Physical memory: divided into memory available for running programs and system cache for virtual memory.
The total corresponds to the RAM size (see system properties).

Commit charge: shows the total of physical and virtual memory

Kernel

 

System Shutdown Problems

Recovery Console Commands

Recovery Console needs Setup CD or pre-install with "...\i386\winnt32.exe /cmdsons".

listsvc
List all the services and device drivers. Scroll with ENTER, quit with ESC.
enable <service> [StartType]
Get the name of the service from the command listsvc. StartType is one of: SERVICE_BOOT_START (if required for operating system), SERVICE_SYSTEM_START (normal operating start), SERVICE_AUTO_START (auto start) or SERVICE_DEMAND_START (manual start).
disable <service>
Remember to note the previous state of the service.
copy
Use for replacing a corrupted file
delete
 
dir
List directory
dir /b : just file names, no header or other information
dir file.name /s : searches in the directory tree, lists the entry, and the directory it is in.
more
 
type
Display contents of a file

Devices

Start > programs > administrative tools > computer management > Device Manager

Disks

Mast Boot Record (MBR)
On first sector of the first partition. Contains the information on partitions, and also some executable code that is loaded into RAM at startup.
Boot sector
Next sector on first partition, first sector on other partitions. Information for booting the operating system. E.g. indicates boot.ini.
boot.ini file
Contains "Advanced RISC Computing" paths (ARC). Useful to edit when have to boot only on one side of a mirrored disk.
Faster File Table (MFT)
Stores attributes for all folders and files. Normally resides on the first 12.5 % of the disk.

boot.ini

scsi: SCSI disks for which the controller's SCSI BIOS is disabled; use "disk" parameter (tip: 4 letters).
multi: IDE disks, and SCSI disks when SCSI BIOS is enabled; use "rdisk" parameter (tip: 5 letters).
Note that partition values start at 1, but other values start at 0.

Edit the boot.ini with the bootcfg command.

Examples of boot.ini

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINNT="Windows NT Workstation Version 4.00"
multi(0)disk(0)rdisk(0)partition(1)\WINNT="Windows NT Workstation Version 4.00 [VGA mode]" /basevideo /sos

Here: first disk, first partition. Option to start in VGA mode.

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows 2000 Professional" /fastdetect
C:\CMDCONS\BOOTSECT.DAT="Microsoft Windows 2000 Recovery Console" /cmdcons

First disk, first partition. Option to start with Recovery Console.

 

Open files (XP):

Openfiles /Query
Shows opened files
Openfiles /Disconnect
Disconnects open files.
Openfiles /Local
Enables/disables the display

 

 

Security

(needs more work)

Note that simple file sharing is allowed in ... (surprise) ... the folder file options:

Simple File Sharing Switch

In 'Tools' > 'Internet Options' > 'Security' (tab) > 'Trusted Sites' > 'Custom Level' (button):
In 'Downloads', set 'Automatic prompting for file downloads' to 'Enable'.
In activeX controls and plugins, set the 'Initialize and script Active X controls not marked as safe' option to 'Prompt'.

Certificate Manager

For windows: certmgr.msc at command line
Firfox: menu options > advanced > certificates. Thunderbird: similar.

 

Verify hash files:
certutil  -hashfile  a_file_name  sha256
type  a_file_name.sha256

 

Virtual Machine

Main settings:

Copy vm:

 


Installation and Setup

 

Preparation for installation

Recommended software:

Some steps for installation

 

 


Networking

Network monitor: start - programs - administrative tools - network

ping -t addr: ping continuously until ctrl-T
ping -a addr: resolve address to host name
ping -w 5000 addr: timeout to wait in milliseconds, here 5000
ping -n 1 addr: send only 1 echo request
ping -t -a -w 10000 10.103.100.21: example

Performance:

Ethernet

 

Network troubleshooting

Network Protocols

 

NetBEUI
NetBIOS Enhanced User Interface used with Windows95/98, especially small office and home office (SOHO). Support dropped in XP and W2003. A NetBIOS name is limited to 15 characters.
NWLink (IPX/SPX)
Frame Type = how the data is encapsulated; windows can only integrate one frame type!
Internal Network Number (eight hexa numbers) ~ hostID
External Network Number ~ network ID

IP Address Structure

Address 197 . 203 . 176 . 213
 
Network ID
Host ID
Address 11000101 . 1100101 1 . 10110000 . 11010101
Network ID 11000101 . 1100101   .   .  
Host ID   .   1 . 10110000 . 11010101
Subnet Mask 11111111 . 1111111 0 . 00000000 . 00000000

Here, the subnet mask is 255.254.0.0 or /15.
Notation /n indicates the number of bits in the subnet mask.
Generally, the subnet masks are 255.0.0.0 or /8, 255.255.0.0/16 or 255.255.255.0/24:

Class Subnet Mask Addresses
Number of
Networks
Hosts per
Network
A
255. 0 . 0 . 0   or  /8 0bbb bbbb.n.n.n  or   1-126.n.n.n
126
16'777'214
B
255.255. 0 . 0   or /16 10bb bbbb.n.n.n  or 128-191.n.n.n
16'384
65'534
C
255.255.255. 0   or /24 11bb bbbb.n.n.n  or 192-223.n.n.n
2'097'152
254

Non-routable IP addresses:

FQDN = Fully Qualified Domain Names = <computer name>.<domain name>.<domain extension>
where the names can begin with numbers, no longer than 255 characters, a-z, A-Z, 0-9 and hyphens (no spaces), case insensitive.

Windows name resolution (order of resolution in W2000 systems and newer):

DHCP

MAC Address
Media Access Control: a 48-bit address embedded on network cards (FF-FF-FF-FF-FF-FF).
DHCP Lease
Computer broadcasts a DHCP Discover packet ("yo DHCP server"). DHCP servers offer an IP address. Computer sends a request to use the address offered by the first DHCP server that responded. The chosen DHCP server sends an acknowledge packet. The address is leased for a period, typically two weeks. At 50% of the lease, the client will try to get a new lease.
DHCP Scope
Defines subnet mak, IP address exclusions, IP address reservations and DHCP options.
DHCP Address Exclusions
Addresses in the subnet mask that are NOT handed out by the DHCP server
DHCP Address Reservations
Reserved address, but this involves knowing the MAC address for each reserved address, so it is better to use IP address exclusions.
DHCP Options
Automatic assignement of default gateway, DNS server(s), DNS domain name, WINS server and WINS node type.
DHCP Relay Agent
Allows contacting a DHCP through a router, because some routers do not relay broadcasts (the first step in the DHCP lease process).

Automatic addressing in Windows2000: if a DHCP server cannot be contacted, the computer gives itself an address in range 169.254.0.1 to 169.254.255.254 /16 (i.e. class B, subnet mask 255.255.0.0). So, if the ipconfig command shows an address 169.254.x.x on W2000, then the DHCP server cannot be contacted.

 

 


Tips for Office

 

Office 2007 Resources:

Basic Training for Office 2007
Microsoft Training Site for all Office 2007 applications

Help for Word 2007
Microsoft Site with Tips, Tricks and Tutorials

Top Tips for Word 2007
Microsoft Site

DEMO on Outlook 2007
Microsoft Training Site

Discontinued Features and Changes in Outlook 2007

Getting Up to Speed with:
Outlook 2007
Word 2007
Excel 2007
PowerPoint 2007

 

Word

Field for date:

{SAVEDATE \@ "yyyy-MM-dd HH:mm" \* MERGEFORMAT}
store save-date in the word document, with yyyy-mm-dd HH:mm format
{DATE \@ "MMM/d/yyyy"}
Current date
{page}
Page
{ DOCPROPERTY "Project" \* MERGEFORMAT }
document properties in file > properties > custom
This properties can then be inserted in the document: file insert > field > document information > DocProperty > Options
Save All
[Shift]+menu file
Vertical selection
Hold the [Alt] key down when making the selection
double-click on the horizontal or vertical ruler
--> Page Setup dialog box
double-click on an indent marker on the horizontal ruler
--> Paragraph dialog box
double-click the Move Table Column marker or the Table Move Handle
--> Table Properties dialog box
Insert a field with the content of one of the headings
menu insert > field > StyleRef > choose heading 1 or heading 2

 

Lost all menus in Word:
in command line: winword -a
   -a recuperates the default options

Switch between viewing results and formulas: CTRL+` (grave accent), or Tools menu > Formula Auditing > Formula Auditing Mode.

Paste from a word table to excel: remove all end-of-paragraph marks in the table, select the whole table, paste special in word (just text).

Bullet lists

Indentations in Word

 

 

Powerpoint

Print in black&white: first reduce the background graphics in the master slide; then set to black and white (menu view > black and white)

Master slide: menu view > master

Manage the indents: make the ruler visible with menu > view > ruler

 

Excel

A spreadsheet used to have a maximum of 65536 rows and 256 columns (up to column IV)
Now the maximum is 1,048,576 rows and 16,384 columns.

Formats in cells:

Command line:
start excel file.name
start excel /r file.name: open read-only
start excel /s file.name: safe mode
Also start winword or start notepad or start powerpnt

 

Excel Functions

List of functions available

Tips

Code for macro to clean up excel sheet:
' Removing tabs and carriage returns from worksheet cells
Sub CleanUp()
Dim TheCell As Range
On Error Resume Next

For Each TheCell In ActiveSheet.UsedRange
With TheCell
If .HasFormula = False Then
.Value = Application.WorksheetFunction.Clean(.Value)
End If
End With
Next TheCell
End Sub

To transform columns into rows or vice-versa, copy and then paste special with the "transpose" option.

ctrl+Page up/down: go to next/previous tab

 

Comma or tab separated file

In a comma or tab separated file with data with leading zeros or spaces, precede the value with equals sign (=) and a double quote. Add a double quote after the value: ="000075".
This trick only works in Excel. Other programs cannot handle this.
See also notes on Informatica functions.
Also surround with quotes: if using the csv format and opening the csv file directly, two options, otherwise a third option:
1) selectively surround the fields with commas and end-of-line characters with double quotes
2) or surround all fields with double quotes and double-up the double quotes in: =""000075""
3) If opening the file with the import wizard, surround with single quotes, not double quotes.

Office shortcut keys

[Alt] + [Ctrl] + [- on Num pad] Em dash
[Ctrl] + [- on Num pad] En dash
[Ctrl] + [ _ ] ([Ctrl] + [Shift] + [- _]) Non-breaking hyphen
[Ctrl] + [-] Optional hyphen

Other characters: see chars.html
Windows shortcut keys: see Section on basics
For end of line characters, see chars.html

 


Open Office

 

Bullet lists

hard space: ^space

 


Outlook

Express:

Storage of digital signatures: documents and settings\ username\ application data\ microsoft\ signatures. Three files: .txt, .rtf, .htm. (outlook full)

Create personal folders: menu tools > services > tab services > add button (for exchange servier) > personal folders
To create new outlook personal folder that can be put on any disk: menu file > new > personal folder (*.pst).

 


Scripting

 

F7 shows the recently types commands. Same as doskey /history

Some pre-defined variables:

%date% %time% %userprofile%

IF [NOT] ERRORLEVEL number command
IF [NOT] string1==string2 command
IF [NOT] EXIST filename command

if "%OS%"=="Windows_NT" setlocal

if "%2"=="" goto usage
. . .
goto exit
:usage
echo Usage: the_command userid passwd

echo %%1%%

set h10=%time:~0,1%
if "%h10%"==" " set datetimef=%date:~-4%_%date:~0,3%_%date:~4,2%_0%time:~1,1%%time:~3,2%%time:~6,2%
if "%h10%"=="0" set datetimef=%date:~-4%_%date:~0,3%_%date:~4,2%_%time:~0,2%%time:~3,2%%time:~6,2%
if "%h10%"=="1" set datetimef=%date:~-4%_%date:~0,3%_%date:~4,2%_%time:~0,2%%time:~3,2%%time:~6,2%

This assumes that the date format is "dd mon yyyy".

Substring, from 5th position (0 is 1st), 3 characters: %a_string:~4,3%
Last 4: %a_string:~-4%

 

Stop services:
NET STOP "service name in full"

Map disk (need to work on this):
NET USE ...

 

This removes all files, then all sub-directories:
del   /S /Q C:\dir\subdir
rmdir /S /Q C:\dir\subdir
pause
exit

 

cd a_directory
Change a directory. ".." to go up
cd /D X:\...\a_directory
Change a directory and change disk too
set var
Show value of a variable
set var=a_value
Set the value of a variable. Any spaces after the equal sign will be part of the value. Quotes are not necessary
set /A expression
The part to the right of the "=" sign is an expression to be evaluated.
See the help for details.
set /P variable[=a_prompt_string]
Displays prompt and assigns user input to the variable.
Example: set /P the_pw=Enter password for %the_user%:
pause a_message
Pause execution, display message and wait for user to press a key
rem a remark
Comment
call an_executable
Call a program, without leaving the current batch
start application
Stat an application, such as excel, word, ...
echo a text .. ^< ^>
Echo to screen; escape "<" and ">" with carot "^"
date /T
time /T
Just display the date or time
type a_file
Display the contents of the file
xcopy /D:01-31-2008 /S /Y source_dir target
Copy all files modified after date. S option copies sub-directories too. Y option suppresses the prompts to overwrite.
See sample code below
findstr /l /i the_string_to_search *.sql
Similar to grep. Includes use of regular expressions(/r)). See help with findstr /?
/l --> search literally, as opposed to regular expression (/r)
/b --> at beginning of line
/e --> at end of line
/s --> sub-directories too
/i --> case INsensitive
glu
glu
glu
glu
glu
glu

 

date /T > copy_log.log
time /T >> copy_log.log
del /F /S /Q G:\target\the_dir\*.* >> copy_log.log
date /T >> copy_log.log
time /T >> copy_log.log
xcopy /S /C /H /R /Y C:\the_source\the_dir G:\target\the_dir >> copy_log.log
date /T >> copy_log.log
time /T >> copy_log.log
echo Done >> copy_log.log

 

%CD% --> current directory
%DATE% --> current date using same format as DATE command.
%TIME% --> current time using same format as TIME command.
%ERRORLEVEL% --> ERRORLEVEL value
For others, see help set.

Path and variables
right click on start button >
menu settings > system > about > related settings / system info > advanced tab > button at bottom "env var"

See where the executable is installed: where executable

 
FOR %variable IN (set) DO command [command-parameters]

  %variable Specifies a replaceable parameter.
  (set)      Specifies a set of one or more files.  Wildcards may be used.
  command    Specifies the command to carry out for each file.
  command-parameters
             Specifies parameters or switches for the specified command.

To use the FOR command in a batch program, specify %%variable instead
of %variable Variable names are case sensitive, so %i is different
from %I. 
 
Example:
rem Parameter 1: the target SID
rem Parameter 2: the target schema
set the_sid=%1%
set the_owner=%2%
SQLPLUS.EXE /NOLOG @drop_create_users.sql %the_sid% %the_owner%
set param_file=import_parameter_file_%the_sid%.txt
echo USERID=%the_owner%/%the_owner%@%the_sid% > %param_file%
echo FROMUSER=%the_owner% >> %param_file%
echo TOUSER=%the_owner% >> %param_file%
IMP %the_owner%/%the_owner%@%the_sid% PARFILE=%param_file%
SQLPLUS.EXE /NOLOG @update_db.sql %the_sid% %the_owner%
%SystemRoot%\system32\notepad.exe ..\files\drop_create_users.log
pause

 

For end of line characters, see chars.html

 

 

 

 


Another example:

@ECHO OFF

REM ***********************************************
REM ** Define the variables
REM ***********************************************

SET THE_DIR=c:\whatever\v1.3
SET PARAM_FILE=c:\abcd\def.dat

ECHO **********************************************
ECHO ** Step 1
ECHO **********************************************
SET STEP=1
%THE_DIR%\sub-dir\bin\the_prog %PARAM_FILE%
IF ERRORLEVEL 1 GOTO ABEND
ECHO.

ECHO **********************************************
ECHO ** Step 2
ECHO **********************************************
SET STEP=2
...and so on....
IF ERRORLEVEL 1 GOTO ABEND
ECHO.

ECHO SCRIPT COMPLETED SUCCESSFULLY
GOTO END

:ABEND
ECHO SCRIPT FAILED ON STEP %STEP%

:END

 

Powershell

dir env:
See environment variables

$env:VAR_NAME = ‘a value’ Set a variable
$env:VAR_NAME += ‘;a value’ Add to a variable (notice "+" sign)


 

 


Troubleshooting

Troubleshooting windows system

Troubleshooting Network

See [1].

Identifying the problem What happened?
What error messages? (read the error message before clicking the "OK")
Documenting the history of the problem

What are the recent changes on the computer?

  • Recent hardware or software installations?
  • Recent error messages?
  • Single user only or other users too?
  • Last backup of the computer?
  • With what application or action is the error related?
  • See event log
Analyzing the current environment
  • What is operating system version and service pack?
  • Latest virus definitions and latest scan?
  • Network configuration (ipconfig /all)?
  • Firmware?
  • Compare with a similar computer that is working
  • Compare with known "good" situation (prepare documentation of the existing situations)
Documenting processes involved in the problem Picture...
What are the dependencies between processes...
Eliminating what works
  • Go to a quiet place
  • Don't reinvent the wheel
  • See support sites on internet, especially if we are paying for support
  • Document the checks that are done so as not the continuously re-check
  • Write down everything that was done
  • Top-down
  • Try possible solutions one at a time
  • Try the easiest solutions first
Correcting the problem Process-Oriented Corrective Action, i.e. correct the underlying cause of the problem.
Testing the corrective action Test before announcing that all is corrected.
Following up with wider maintenance Apply the lessons learned.

Troubleshooting

 

Checklist of information to know

 

Some Past Problems

Symptom Tools for diagnostic Problem Resolution
Slow when logging on ipconfig /all DNS and WINS pointing to the wrong machine Network properties > tab Protocols > TCPIP protocol > button properties
Slow spybot or other Undesirable programs Also try the immunize so that the problems don't come back
Sites re-directed in the browser   Extra lines added to hosts file Remove the lines
IE browser has odd behavior   Extra add-ins running Remove: tools > options > settings > view objects
Wireless device was disabled   ? Add hardware, choose add existing hardware (the driver showed with a red X)
Issues in connection to web site     Add the domain to the list of trusted sites in tools > internet options > security tab > trusted sites > sites. Remove the check in "require server verification."
Cannot connect to network   Network connection disabled In control panel > network connections, enable the connection.
Computer is "thinking" too much Diagnostics option at boot Memory failing  
C disk is full   Old files Empty files in:
C:\WINNT\SoftwareDistribution\Download (net stop/start wuauserv)
C:\WINNT\system32\LogFiles

 

Some Anti-virus links

 


Miscellaneous

 

Get current version of operating system: type winver in command line.
Current version of of directx: dxdiag

For browsing Internet, use a non-administrator user

GnuWin32Packages

Some links for troubleshooting windows:

Bibliography

[1] Chris Wolf: Troubleshooting Microsoft Technologies, The Ultimate Administrator's Repair Manual, Addison Wesley, 2003.

 

 

Curious behavior: write in word document: =rand(100,1)
=rand(p,s) create random text with p paragraphs and s sentences
=lorem(p,s) create random text
=rand.old(p,s) creates quick ... sentences