Loading

Wednesday, December 9, 2009

Install Windows Server 2008 Features with servermanagercmd.exe at the Command Prompt

Although Microsoft continues to expand PowerShell with more capability, the command prompt has not been left behind in Windows Server 2008. In fact, with this latest Windows Server release, the command prompt gains some capability, including a tool that allows administrators to add or remove features on a Windows Server 2008 installation with servermanagercmd.exe, which replicates some of the functionality from the Windows Server 2008 Server Manager. Through the use of various command line options, you can quickly and easily add or remove features and roles to or from your server.

The command requires a parameter indicating the action that you wish to perform and, for some parameters, additional information such as which features you want to manage. The list below outlines some of the parameters available with servermanagercmd.
  • -query: Output a list of the roles and features currently installed on your server. This command also shows you the roles and features that are available, but not yet installed.
  • -install: Installs the roles or features that you specify on the command line. Add -allSubFeatures to the command line when using -install in order to add the supporting roles/features to a specified parent role/feature. As you are well aware some components require a server reboot in order to complete. To automate a server restart that takes place after the installation of a role/feature requiring a restart, use -restart.
  • -remove: This is the opposite of the install command and removes the specified roles or features.


The table below provides you with a complete list of the components installable using the servermanagercmd command. The first column is the overall feature name. For some features, roles, or services, there are multiple components available. The second column of the table gives you a complete list of all subcomponents while the third column is the identifier to use with the -install or -remove parameter.

Role / Service or Main Feature
R/S/F Name
Installatiom command
DHCP Server
DHCP Server
DHCP
Print Services
Print Server
Print-Services
Internet Printing
Print-Internet
LPD Service
Print-LPD-Service
Terminal Services
Terminal Services
Terminal-Services
Terminal Server
TS-Terminal-Server
TS Licensing
TS-Licensing
TS Gateway
TS-Gateway
TS Web Access
TS-Web-Access
TS Session Broker
TS-Session-Broker
Active Directory Domain Services
AD
N/A
Active Directory Domain Controller
ADDS-Domain-Controller
Identity Management for UNIX
ADDS-Identity-Management
Server for Network Information Service
ADDS-NIS
Password Synchronization
ADDS-Password-Sync
DNS Server
DNS
File Services
File Services
N/A
Distributed File System (DFS)
FS-DFS
DFS Namespace
FS-DFS-Namespace
DFS Replication
FS-DFS-Replication
File Server Resource Manager
FS-Resource-Manager
Services for Network File System
FS-NFS-Services
Windows Search Service
FS-Search-Service
Windows Server 2003 File Services
FS-Win2003-Services
File Replication Service
FS-Replication
Indexing Service
FS-Indexing-Service
Web Server
Web Server (IIS)
Web-Server
Internet Information Services
Web-WebServer
Common HTTP Features
Web-Common-Http
Static Content
Web-Static-Content
Default Document
Web-Default-Doc
Directory Browsing
Web-Dir-Browsing
HTTP Errors
Web-Http-Errors
HTTP Redirection
Web-Http-Redirect
Application Development
Web-App-Development
ASP.NET
Web-Asp-Net
.NET Extensibility
Web-Net-Ext
ASP
Web-ASP
CGI
Web-CGI
ISAPI Extensions
Web-ISAPI-Ext
ISAPI Filters
Web-ISAPI-Filter
Server Side Includes
Web-Includes
Health and Diagnostics
Web-Health
HTTP Logging
Web-Http-Logging
Logging Tools
Web-Log-Libraries
Request Monitor
Web-Request-Monitor
Tracing
Web-Http-Tracing
Custom Logging
Web-Custom-Logging
ODBC Logging
Web-ODBC-Logging
Security
Web-Security
Basic Authentication
Web-Basic-Auth
Windows Authentication
Web-Windows-Auth
Digest Authentication
Web-Digest-Auth
Client Certificate Mapping Authentication
Web-Client-Auth
IIS Client Certificate Mapping Authentication
Web-Cert-Auth
URL Authorization
Web-Url-Auth
Request Filtering
Web-Filtering
IP and Domain Restrictions
Web-IP-Security
Performance
Web-Performance
Static Content Compression
Web-Stat-Compression
Dynamic Content Compression
Web-Dyn-Compression
Management Tools
Web-Mgmt-Tools
IIS Management Console
Web-Mgmt-Console
IIS Management Scripts and Tools
Web-Scripting-Tools
Management Service
Web-Mgmt-Service
IIS 6 Management Compatibility
Web-Mgmt-Compat
IIS 6 Metabase Compatibility
Web-Metabase
IIS 6 WMI Compatibility
Web-WMI
IIS 6 Scripting Tools
Web-Lgcy-Scripting
IIS 6 Management Console
Web-Lgcy-Mgmt-Console
FTP Publishing Service
Web-Ftp-Publishing
FTP Server
Web-Ftp-Server
FTP Management Console
Web-Ftp-Mgmt-Console
Active Directory Federation Services
ADFS
None
Federation Service
ADFS-Federation
Federation Service Proxy
ADFS-Proxy
Web Agents
ADFS-Web-Agents
Claims-aware Agent
ADFS-Claims
Windows Token-based Agent
ADFS-Windows-Token
Active Directory Lightweight Directory Services
Formerly ADAM
ADLDS
Application Server
Application Server
Application-Server
Application Server Core
AS-AppServer-Core
Web Server Support
AS-Web-Support
COM+ Network Access
AS-Ent-Services
TCP Port Sharing
AS-TCP-Port-Sharing
Windows Process Activation Service Support
AS-WAS-Support
HTTP Activation
AS-HTTP-Activation
Message Queuing Activation
AS-MSMQ-Activation
TCP Activation
AS-TCP-Activation
Named Pipes Activation
AS-Named-Pipes
Distributed Transaction Support
AS-Dist-Transaction
Incoming Remote Transactions
AS-Incoming-Trans
Outgoing Remote Transactions
AS-Outgoing-Trans
WS-Atomic Transaction Support
AS-WS-Atomic
Active Directory Certificate Services
Active Directory Certificate Services
N/A
Certification Authority
ADCS-Cert-Authority or AD-Certificate
Online Certificate Status Protocol
ADCS-Online-Cert
Fax Server
Fax Server
Fax
Network Policy and Access Services
Network Policy and Access Services
NPAS
Network Policy Server
NPAS-Policy-Server
NPAS Routing and Remote Access Services
NPAS-RRAS-Services
Remote Access Service
NPAS-RRAS
Routing
NPAS-Routing
Health Registration Authority
NPAS-Health
Windows Deployment Services
Windows Deployment Services
WDS
Hyper-V
Hyper-V
Hyper-V
Failover Clustering
Failover Clustering
Failover-Clustering
Network Load Balancing
Network Load Balancing
NLB
Desktop Experience
Desktop Experience
Desktop-Experience
.NET Framework 3.0 Features
.NET Framework 3.0 Features
NET-Framework
.NET Framework 3.0
.NET Framework 3.0
NET-Framework-Core
XPS Viewer
XPS Viewer
NET-XPS-Viewer
Windows Communication Foundation Activation Components
Windows Communication Foundation Activation Components
NET-Win-CFAC
HTTP Activation
HTTP Activation
NET-HTTP-Activation
Non-HTTP Activation
Non-HTTP Activation
NET-Non-HTTP-Activ
Windows System Resource Manager
Windows System Resource Manager
WSRM
Wireless Networking
Wireless Networking
Wireless-Networking
Windows Server Backup
Windows Server Backup
Backup
WINS Server
WINS Server
WINS-Server
Remote Assistance
Remote Assistance
Remote-Assistance
Simple TCP/IP Services
Simple TCP/IP Services
Simple-TCPIP
Telnet Client
Telnet Client
Telnet-Client
Telnet Server
Telnet Server
Telnet-Server
Subsystem for UNIX-based Applications
Subsystem for UNIX-based Applications
Subsystem-UNIX-Apps
RPC over HTTP Proxy
RPC over HTTP Proxy
RPC-over-HTTP-Proxy
SMTP Server
SMTP Server
SMTP-Server
LPR Port Monitor
LPR Port Monitor
LPR-Port-Monitor
Storage Manager for SANs
Storage Manager for SANs
Storage-Mgr-SANS
BITS Server Extensions
BITS Server Extensions
BITS
Message Queuing
Message Queuing
MSMQ
Message Queuing Services
MSMQ-Services
Message Queuing Server
MSMQ-Server
Directory Service Integration
MSMQ-Directory
Message Queuing Triggers
MSMQ-Triggers
HTTP Support
MSMQ-HTTP-Support
Multicasting Support
MSMQ-Multicasting
Routing Service
MSMQ-Routing
Windows 2000 Client Support
MSMQ-Win2000
Messaging Queue DCOM Proxy
MSMQ-DCOM
Windows Process Activation Service
Windows Process Activation Service
WAS
Process Model
WAS-Process-Model
.NET Environment
WAS-NET-Environment
Configuration APIs
WAS-Config-APIs
Windows Internal Database
Windows Internal Database
Windows-Internal-DB
BitLocker Drive Encryption
BitLocker Drive Encryption
BitLocker
Multipath I/O
Multipath I/O
Multipath-IO
Internet Storage Naming Server
Internet Storage Naming Server
ISNS
Removable Storage Manager
Removable Storage Manager
Removable-Storage
TFTP Client
TFTP Client
TFTP-Client
SNMP Services
SNMP Services
SNMP-Services
SNMP Service
SNMP-Service
SNMP WMI Provider
SNMP-WMI-Provider
Services for Network File System
Services for Network File System
NFS-Services
Internet Printing Client
Internet Printing Client
Internet-Print-Client
Peer Name Resolution Protocol
Peer Name Resolution Protocol
PNRP
Connection Manager Administration Kit
Connection Manager Administration Kit
CMAK
Remote Server Administration Tools
Remote Server Administration Tools
RSAT
Role administration tools
RSAT-Role-Tools
Active Directory Certificate Services Tools
RSAT-ADCS
Active Directory Domain Services Tools
RSAT-ADDS
Active Directory Domain Controller Tools
RSAT-ADDC
Server for NIS Tools
RSAT-SNIS
Active Directory Lightweight Directory Services Tools
RSAT-ADLDS
Active Directory Rights Management Services (AD RMS) Tools
RSAT-RMS
DHCP Server Tools
RSAT-DHCP
DNS Server Tools
RSAT-DNS
Fax Server Tools
RSAT-Fax
DFS Management Console Tools
RSAT-DFS-Mgnt-Con
File Server Resource Manager Management Console Tools
RSAT-FSRM-Mgnt
Hyper-V Tools
RSAT-Hyper-V
Services for Network File System Tools
RSAT-NFS-Admin
File Services Tools
RSAT-File-Services
Network Policy and Access Services Tools
RSAT-NPAS
Health Registration Authority Tools
RSAT-HRA
Network Policy Server Tools
RSAT-NPS
Print Services Tools
RSAT-Print-Services
Web Server (IIS) Tools
RSAT-Web-Server
Terminal Services Tools
RSAT-TS
TS RemoteApp Tools
RSAT-TS-RemoteApp
TS Gateway Tools
RSAT-TS-Gateway
TS Licensing Tools
RSAT-TS-Licensing
UDDI Services Tools
RSAT-UDDI
Feature administration tools
RSAT-Feature-Tools
BitLocker Drive Encryption Tools
RSAT-BitLocker
BITS Server Extensions Tools
RSAT-BITS-Server
Failover Clustering Tools
RSAT-Clustering
Network Load Balancing Tools
RSAT-NLB
SMTP Server Tools
RSAT-SMTP
Windows Deployment Services Tools
RSAT-WDS
WINS Server Tools
RSAT-WINS
Hyper-V Tools
RSAT-Hyper-V
Windows PowerShell
Windows PowerShell
PowerShell
Group Policy Management
Group Policy Management
GPMC
Quality Windows Audio Video Experience
Quality Windows Audio Video Experience
Qwave

Examples
  • Using servermanagercmd to activate terminal services
You can selectively enable terminal server services with:
servermanagercmd -install TS-TerminalServer
Terminal Services options
[ ] Terminal Services  [Terminal-Services]
    [ ] Terminal Server  [TS-Terminal-Server]
    [ ] TS Licensing  [TS-Licensing]
    [ ] TS Session Broker  [TS-Session-Broker]
    [ ] TS Gateway  [TS-Gateway]
    [ ] TS Web Access  [TS-Web-Access]

Manage Windows 2008 Licenses with slmgr.vbs from the command line

Windows 2008 Servers supports license management from the command line, using slmgr.vbs.  With it you can see how much time you have left on an eval, add or uninstall licenses and much more. The name of the tool is actually Windows Software Licensing Management Tool.  It is a visual basic script used to configure licensing on any Windows 2008 Server – either the full version or the core version. To see what slmgr.vbs can do, you can simply open a Windows command prompt (with cmd.exe) and type:
slmgr.vbs /?


Figure 1: Help window for slmgr.vbs

This displays a help window that will show you all the slmgr.vbs options. Here are the various tasks you can perform with slmgr.vbs:
  • Manage licensing not only on the local server but also on remote Windows 2008 Servers, over the network. A username and password is required for this. If a server is not specified it will default to the localhost.
  • –ipk: Install product keys
  • –ato: Activate Windows 2008
  • –dli: Display license information
  • –dlv: Display detailed license information
  • –xpr: Show when the current Windows license will expire
  • –cpky: Clear the current Windows product key from the registry (for security reasons)
  • –ilc: Install a license
  • –rilc: Reinstall system license files
  • –rearm: Reactive a Windows evaluation license
  • –upk: Uninstall a certain product key
  • –dit: Display your installation ID, used by Microsoft for offline (telephone) activation
  • –ato: Active a product with the confirmation ID
Here are some examples of how Windows 2008 slmgr.vbs can be used.

How can slmgr.vbs help with Evaluation licensing?

If you are evaluating Windows Server 2008, you should know that license activation is not required. An evaluation version of Windows Server 2008 will work for 60 days. While many admins do not know it, you can “re-arm” that evaluation period for another 60 days, three times over. Thus, you could evaluate Windows 2008 Server for a total of 240 days, or about 8 months.

You can re-arm this evaluation of Windows 2008 using slmgr.vbs. To do this, just type:
slmgr.vbs –rearm

Figure 2: Results after rearming your Win 2008 evaluation copy for another 60 days.

To see how much time you have left in your current evaluation period, just type:
slmgr.vbs –xpr

Figure 3: Results of xpr command, showing the date and time that the license grace period for Win 2008 expires.

Microsoft has a knowledgebase document on how to automatically extend the evaluation of licensing with a script. By implementing this script, you could use Windows Server 2008 for the full 240 days without having to do anything. For more information on that, please see Microsoft KB 948472.

How do I get detailed information on my Windows Server 2008 license?

To get more detailed information than just the expiration date (given by the xpr command), you can use the dli or dlv options. Here is what their output looks like:

Figure 4: slmgr.vbs –dli output showing license information.

As you  can see in the –dli option output, there is more information on the version of Win 2008 you are running, the license status, time renaming (down to the second), and all about the key management server.

Figure 5: slmgr.vbs –dlv output showing detailed license information

With the –dlv option, there is even more detailed information about the current state of your licenses.

How can I activate my license in Windows 2008 Server Core?

In Windows Server Core, with only a command prompt, you are forced to use slmgr.vbs to activate your Core server from the command line. Thus, it is much more critical to know how to use slmgr.vbs if you are using Windows Server Core. Still, every Admin, in my opinion, should know the basics of using it.

Let’s assume that you entered a product key during the installation of Windows 2008 Server Core. To activate your OS, just type:
slmgr.vbs –ato
If you do not have networking configured, or you get another error, you will get a window that says something like this:

Figure 6: Error from slmgr license activation

If you did not enter a product key during the install process, you can enter one with slmgr.vbs at the command line with:
slmgr.vbs –ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
From there, you can attempt the auto activation again.

Figure 7: Successful activation of Windows 2008 with slmgr.vbs

If you are successful you should see the “product activated successfully” window, as displayed in Figure 7.

How do I administer licensing of a remote Windows 2008 Server using slmgr.vbs?

Just enter the machinename, username, and password between the slmgr command and the options, like this:
slmgr.vbs <ServerName> administrator <Password> -xpr

Summary

slmgr.vbs is a useful, and often, essential all admins should know.

How to: Reverse DNS from Windows Command Line using Ping

Here's a quick and easy way to do a Reverse DNS (RDNS) lookup using ping.exe from a Windows command prompt using the -a switch.
ping -a <IP Address>
Example
ping -a 76.96.54.12
This example will resolve the address as follows:
Pinging www4.comcast.net [76.96.54.12] with 32 bytes of data:

Reply from 76.96.54.12: bytes=32 time=66ms TTL=51
Reply from 76.96.54.12: bytes=32 time=7ms TTL=51
Reply from 76.96.54.12: bytes=32 time=7ms TTL=51
Reply from 76.96.54.12: bytes=32 time=7ms TTL=51

Ping statistics for 76.96.54.12:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 7ms, Maximum = 66ms, Average = 21ms

Unzip rar files in Ubuntu with unrar

Often it is necessary to extract files. zip and tar.gz files can be opened directly in Ubuntu (and other flavors of Linux), but rar is not supported by default. You should install and use unrar to extract rar files.
% sudo apt-get install unrar
Two useful and probably most used command are:
% unrar e your-file-name.rar 
Extracts the rar file in the current directory.
% unrar l your-file-name.rar 
Lists the content of the rar file.

Tuesday, December 8, 2009

Getting the Most out of Windows Command Prompt

If you are like me you use the command prompt a lot.  It seems each time I logon to a new system I have to setup the command prompt just the way I want.  The first thing I do is create a shortcut in the Quick Launch toolbar.  Next I modify that shortcut so it will better suit my needs.

Right-click the shortcut and select Properties.  On the Shortcut tab add " /f:on" (without the quotes) to the Target - make sure there is a space between cmd.exe and /f:on, and if cmd.exe ends with a quote place the /f:on outside the quotes. This will enable file and directory name completion characters - you can use Ctl + d for directories and Ctl + f for files.  I also like to set the Start In target to C:\.



Click the Options tab.  I like to increase the command history buffer to at least 100, this is especially useful if you have a command prompt open for a long time and want to scroll back through your previous commands.  Check discard old duplicates to, well, do just that.  And check QuickEdit mode.  This is a great one as it enables selecting text directly and pasting directly (with right-click) without having to right-click and select copy and/or paste.



Personally I don't change the fonts or colors, but you may prefer different settings.  Play around, have fun.

Now click the Layout tab.  I normally increase the height and width of the window size a bit, especially with today's higher resolution monitors.  And I definitely increase the screen buffer size height, usually to a couple thousand or more.  Make sure to increase the screen buffer width to at least match that of your window size width.



I usually leave "Let System Position Window" checked so Windows will tile subsequent command prompt windows:



See also:

CMD.exe /? (help) in Windows 7
Starts a new instance of the Windows command interpreter


CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF] [[/S] [/C | /K] string]

/C      Carries out the command specified by string and then terminates
/K      Carries out the command specified by string but remains
/S      Modifies the treatment of string after /C or /K (see below)
/Q      Turns echo off
/D      Disable execution of AutoRun commands from registry (see below)
/A      Causes the output of internal commands to a pipe or file to be ANSI
/U      Causes the output of internal commands to a pipe or file to be Unicode
/T:fg   Sets the foreground/background colors (see COLOR /? for more info)
/E:ON   Enable command extensions (see below)
/E:OFF  Disable command extensions (see below)
/F:ON   Enable file and directory name completion characters (see below)
/F:OFF  Disable file and directory name completion characters (see below)
/V:ON   Enable delayed environment variable expansion using ! as the
        delimiter. For example, /V:ON would allow !var! to expand the
        variable var at execution time.  The var syntax expands variables
        at input time, which is quite a different thing when inside of a FOR
        loop.
/V:OFF  Disable delayed environment expansion.

Note that multiple commands separated by the command separator '&&'
are accepted for string if surrounded by quotes.  Also, for compatibility
reasons, /X is the same as /E:ON, /Y is the same as /E:OFF and /R is the
same as /C.  Any other switches are ignored.

If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic is
used to process quote (") characters:

    1.  If all of the following conditions are met, then quote characters
        on the command line are preserved:

        - no /S switch
        - exactly two quote characters
        - no special characters between the two quote characters,
          where special is one of: &<>()@^|
        - there are one or more whitespace characters between the
          two quote characters
        - the string between the two quote characters is the name
          of an executable file.

    2.  Otherwise, old behavior is to see if the first character is
        a quote character and if so, strip the leading character and
        remove the last quote character on the command line, preserving
        any text after the last quote character.

If /D was NOT specified on the command line, then when CMD.EXE starts, it
looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if
either or both are present, they are executed first.

    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun

        and/or

    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

Command Extensions are enabled by default.  You may also disable
extensions for a particular invocation by using the /E:OFF switch.  You
can enable or disable extensions for all invocations of CMD.EXE on a
machine and/or user logon session by setting either or both of the
following REG_DWORD values in the registry using REGEDIT.EXE:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions

        and/or

    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions

to either 0x1 or 0x0.  The user specific setting takes precedence over
the machine setting.  The command line switches take precedence over the
registry settings.

In a batch file, the SETLOCAL ENABLEEXTENSIONS or DISABLEEXTENSIONS arguments
takes precedence over the /E:ON or /E:OFF switch. See SETLOCAL /? for details.

The command extensions involve changes and/or additions to the following
commands:

    DEL or ERASE
    COLOR
    CD or CHDIR
    MD or MKDIR
    PROMPT
    PUSHD
    POPD
    SET
    SETLOCAL
    ENDLOCAL
    IF
    FOR
    CALL
    SHIFT
    GOTO
    START (also includes changes to external command invocation)
    ASSOC
    FTYPE

To get specific details, type commandname /? to view the specifics.

Delayed environment variable expansion is NOT enabled by default.  You
can enable or disable delayed environment variable expansion for a
particular invocation of CMD.EXE with the /V:ON or /V:OFF switch.  You
can enable or disable delayed expansion for all invocations of CMD.EXE on a
machine and/or user logon session by setting either or both of the
following REG_DWORD values in the registry using REGEDIT.EXE:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\DelayedExpansion

        and/or

    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\DelayedExpansion

to either 0x1 or 0x0.  The user specific setting takes precedence over
the machine setting.  The command line switches take precedence over the
registry settings.

In a batch file the SETLOCAL ENABLEDELAYEDEXPANSION or DISABLEDELAYEDEXPANSION
arguments takes precedence over the /V:ON or /V:OFF switch. See SETLOCAL /?
for details.

If delayed environment variable expansion is enabled, then the exclamation
character can be used to substitute the value of an environment variable
at execution time.

You can enable or disable file name completion for a particular
invocation of CMD.EXE with the /F:ON or /F:OFF switch.  You can enable
or disable completion for all invocations of CMD.EXE on a machine and/or
user logon session by setting either or both of the following REG_DWORD
values in the registry using REGEDIT.EXE:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar
    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar

        and/or

    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar
    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar

with the hex value of a control character to use for a particular
function (e.g.  0x4 is Ctrl-D and 0x6 is Ctrl-F).  The user specific
settings take precedence over the machine settings.  The command line
switches take precedence over the registry settings.

If completion is enabled with the /F:ON switch, the two control
characters used are Ctrl-D for directory name completion and Ctrl-F for
file name completion.  To disable a particular completion character in
the registry, use the value for space (0x20) as it is not a valid
control character.

Completion is invoked when you type either of the two control
characters.  The completion function takes the path string to the left
of the cursor appends a wild card character to it if none is already
present and builds up a list of paths that match.  It then displays the
first matching path.  If no paths match, it just beeps and leaves the
display alone.  Thereafter, repeated pressing of the same control
character will cycle through the list of matching paths.  Pressing the
Shift key with the control character will move through the list
backwards.  If you edit the line in any way and press the control
character again, the saved list of matching paths is discarded and a new
one generated.  The same occurs if you switch between file and directory
name completion.  The only difference between the two control characters
is the file completion character matches both file and directory names,
while the directory completion character only matches directory names.
If file completion is used on any of the built in directory commands
(CD, MD or RD) then directory completion is assumed.

The completion code deals correctly with file names that contain spaces
or other special characters by placing quotes around the matching path.
Also, if you back up, then invoke completion from within a line, the
text to the right of the cursor at the point completion was invoked is
discarded.

The special characters that require quotes are:
    
     &()[]{}^=;!'+,`~

Monday, December 7, 2009

Create Windows Shortcuts With a Script at the Command Line

If you are like me you 1) access numerous Windows computers, in my case mainly servers through Remote Desktop; and 2) like to have your Windows desktop setup a certain way.  Here are some examples of a quick and easy way to create shortcuts with a script.  These examples are Visual Basic Scripts (.vbs) and use Windows Script Host to execute.  Create any or all of the examples and execute it from either the command prompt or Start / Run using:
wscript xyz.vbs
Note: These scripts were all tested on Windows 7, Windows 2008 and 2003.  They should run fine on earlier versions of Windows (XP, Vista, 2000, etc.) as well.

Although most of these examples will create shortcuts to Windows Explorer (the last one is a shortcut to the Command Prompt), they are being placed in different locations.  Of course you could modify the examples to launch any program of your choosing.  Additionally you could combine them into one script that could be launched the first time you logon.

For easy reference I highlighted the values you may want to change to tailor the script to your needs.

Windows 7, Vista and Windows 2008 Server note: You will probably have to execute these with administrative rights.  One way to do this is to launch a command prompt (the old fashioned way - Start [All] Programs / Accessories / Command Prompt) using right-click and selecting "Run As Administrator."






Example 1 - Shortcut to Windows Explorer in the "All Users" Desktop folder.  I named the script Explorer_Shortcut_on_AU_Desktop.vbs.
set WshShell = WScript.CreateObject("WScript.Shell" )
strDesktop = WshShell.SpecialFolders("AllUsersDesktop" )
set oShellLink = WshShell.CreateShortcut(strDesktop & "\Windows Explorer.lnk" )
oShellLink.TargetPath = "%SYSTEMROOT%\explorer.exe"
oShellLink.WindowStyle = 1
oShellLink.IconLocation = "%SystemRoot%\explorer.exe"
oShellLink.Description = "Windows Explorer"
oShellLink.WorkingDirectory = "%HOMEPATH%"
oShellLink.Save
Example 2 - Shortcut to Windows Explorer in the "All Users" Start Menu folder.  I named the script Explorer_Shortcut_in_AU_Startmenu.vbs.
set WshShell = WScript.CreateObject("WScript.Shell" )
strStartMenu = WshShell.SpecialFolders("AllUsersStartmenu" )
set oShellLink = WshShell.CreateShortcut(strStartMenu & "\Windows Explorer.lnk" )
oShellLink.TargetPath = "%SYSTEMROOT%\explorer.exe"
oShellLink.WindowStyle = 1
oShellLink.IconLocation = "%SystemRoot%\explorer.exe"
oShellLink.Description = "Windows Explorer"
oShellLink.WorkingDirectory = "%HOMEPATH%"
oShellLink.Save
Example 3 - Shortcut to Windows Explorer in the "All Users" Startup folder.  I named the script Explorer_Shortcut_in_AU_Startup.vbs.  This will cause one instance of Windows Explorer to launch during logon.  If you're like me you will be using it anyway, so why not have it open automatically.
set WshShell = WScript.CreateObject("WScript.Shell" )
strStartup = WshShell.SpecialFolders("AllUsersStartmenu" )
set oShellLink = WshShell.CreateShortcut(strStartup & "\programs\startup\Windows Explorer.lnk" )
oShellLink.TargetPath = "%SYSTEMROOT%\explorer.exe"
oShellLink.WindowStyle = 1
oShellLink.IconLocation = "%SystemRoot%\explorer.exe"
oShellLink.Description = "Windows Explorer"
oShellLink.WorkingDirectory = "%HOMEPATH%"
oShellLink.Save
Example 4 - Shortcut to Windows Explorer in the "Current User" Quick Launch toolbar.  I named the script Explorer_Shortcut_in_CU_QuickLaunch.vbs.
set WshShell = WScript.CreateObject("WScript.Shell" )
strStartup = WshShell.SpecialFolders("AppData" )
set oShellLink = WshShell.CreateShortcut(strStartup & "\Microsoft\Internet Explorer\Quick Launch\Windows Explorer.lnk" )
oShellLink.TargetPath = "%SYSTEMROOT%\explorer.exe"
oShellLink.WindowStyle = 1
oShellLink.IconLocation = "%SystemRoot%\explorer.exe"
oShellLink.Description = "Windows Explorer"
oShellLink.WorkingDirectory = "%HOMEPATH%"
oShellLink.Save
Example 5 - Shortcut to Command Prompt in the Quick Launch toolbar for you, the current user.  I named the script CMD_Shortcut_in_CU_QuickLaunch.vbs.
set WshShell = WScript.CreateObject("WScript.Shell" )
strStartup = WshShell.SpecialFolders("AppData" )
set oShellLink = WshShell.CreateShortcut(strStartup & "\Microsoft\Internet Explorer\Quick Launch\Command Prompt.lnk" )
oShellLink.TargetPath = "%SYSTEMROOT%\system32\cmd.exe"
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "Ctrl+Alt+C"
oShellLink.IconLocation = "%SystemRoot%\system32\cmd.exe"
oShellLink.Description = "Windows Command Prompt"
oShellLink.WorkingDirectory = "%HOMEPATH%"
oShellLink.Save
See also:

5 Great Notepad++ Features

Notepad++ is probably the best text editor for Windows - and it's FREE. It has a huge range of features for working with text files, scripts, HTML files, etc.  Here are some pointers on just a few of those features.

1. Set Language to match your code
One very nice feature of Notepad++ is the ability to color pieces of code. This is very useful when writing C, SQL, HTML or other types of files, allowing you to easily visually distinguish between functions, reserved words, comments, text, and other types of symbols and expressions in your code.

Notepad++ will automatically detect your code based upon the language selected. You can specify the language yourself or Notepad++ will set it based on the file extension.

HTML as text before specifying language.

HTML code after specifying language.

2. Bulk find & replace
If you want to replace a certain entry in your file(s), Notepad++ is the ticket. Not only can it instantly search through all entries in a file, it can search all open files or even all files in a directory (including sub-directories), including, matching only certain file types.

3. Search and replace using regular expressions
When it comes to finding what you want, Notepad++ is not limited to mere words. You can also use powerful regular expression to match dynamic entries. For example, the below search will find (and replace) all tags in the source of HTML files, regardless of the actual image size specified:

Of course, some knowledge of regular expressions is required to use this feature. Not surprisingly, these regular expressions will also serve you well if you dabble in the Linux command line with sed or awk commands.

4. Tidy HTML code

If you're writing web articles, there's a fair chance your code will include a bit of unnecessary breaks, misaligned tags and so forth. Notepad++ can Tidy your HTML code.
For example, here is some unformatted text:

Which we want to format with HTML:

5. Save all open files
While this may not sound too exciting, imagine you have several open files - Notepad++ behaves like Firefox in this regard and opens documents in tabs - each one changed after you ran a bulk find & replace earlier. Saving them one by one can be tedious. Notepad++ saves you the hassle. You can save all open files at once.

Similarly, you can close them all at once.

Conclusion

Notepad++ is an extremely powerful and useful tool. We only scratched the surface on its features. With Notepad++ you can use macros or function completion, compare documents, export files to other formats, and a whole lot more.

Notepad++ also has many useful plugins and it comes in a portable version.

More on Notepad++

Launch Windows Event Viewer From the Command Line or Run Command

You can easily launch Windows event viewer from run line or command prompt using:
eventvwr.msc

Best free PC Benchmark tools for Windows

Prime95 - test system stability. Prime95 has become extremely popular among PC enthusiasts and overclockers as a stability testing utility. It includes a "Torture Test" mode designed specifically for testing PC subsystems for errors in order to help ensure the correct operation of Prime95 on that system, which effectively stress-tests a PC.

HD Tach - hard drive benchmark tool that tests the sequential read, random access and interface burst speeds of the attached storage device (hard drive, flash drive, removable drive etc). Drive technologies such as SCSI, IDE/ATA, IEEE 1394, USB, SATA and RAID are supported.


CrystalMark - benchmark suite, that lets you to test your CPU, memory, HDD and video (GDI, Direct Draw, OpenGL).

NoveBench


  • Extensive CPU speed tests
  • Multi-threaded tests take advantage of multiple cores/processors
  • Hardware accelerated graphics tests
  • Hard drive write speed test
  • CPU temperature monitor
  • Tabbed interface for benchmark results
  • Outputs overall system score
  • Online score comparison system.
  • Freeware.

Alternatives to HyperTerminal in Windows 7 and Vista

Beginning with Windows Vista Microsoft removed HyperTerminal (aka HyperTerm & Hyper Terminal).  Of course, this means it isn't in Windows 7 either. There are several options you can use to replace its functionality.
  • PuTTY - My Recommendation
    • PuTTY is a free implementation of Telnet and SSH for Win32 and Unix platforms, along with an xterm terminal emulator.
  • WinRS (Windows Remote Shell)
    • If you only need remote shell access, you can use WinRS which was introduced in Windows Vista. To get help and see execution options with WinRS, run winrs /? at a command prompt.
  • Telnet is a simple, text-based program that you can use to connect to other devices over your local network or over the Internet.  Telnet can be executed right from the command prompt, although you may have to enable it in Control Panel.

  • Phone and Modem Options can be used to troubleshoot modem problems
    • Open Phone and Modem Options by clicking the Start button, Control Panel, Hardware and Sound, finally Phone and Modem Options.
  • Realterm is a terminal program specially designed for capturing, controlling and debugging binary and other difficult data streams. It is far better for debugging comms than Hyperterminal. It has no support for dialing modems, etc – that is what hyperterminal does.

  • TeraTerm is another alternative to HyperTerminal.  Tera Term is a free software terminal emulator (communication program) which supports:



    • Serial port connections.
    • TCP/IP (telnet, SSH1, SSH2) connections.
    • IPv6 communication.
    • VT100 emulation and selected VT200/300 emulation.
    • TEK4010 emulation.
    • File transfer protocols (Kermit, XMODEM, ZMODEM, B-PLUS and Quick-VAN).
    • Scripts using the "Tera Term Language".
    • Japanese, English, Russian and Korean character sets.
    • UTF-8 character encoding.



  • AbsoluteTelnet Telnet, SSH, and SFTP Client.  AbsoluteTelnet / SSH is a secure flexible terminal client that is suitable for developers, administrators, or deployment across the enterprise. It includes the industry standard SSH protocols to secure terminal session data across insecure environments such as the internet. Its new tabbed interface is a favorite among AbsoluteTelnet users.

  • XP's Hyper Terminal
    • If you really want (or just can't be without it) you can still use XP's Hyper Terminal. Just copy the following two files from an existing XP, Windows 2000 or 2003 box or extract them from the installation CD's of the previous OS's: hypertrm.dll and hypertrm.exe. Although you could put them anywhere on the disk as installation is not required, you may want to place them in %SYSTEMROOT% (normally C:\Windows\System32).