My Blog List

hotinit.com. Powered by Blogger.

Search This Blog

Free Google Online Chat Support For Website and Blogs

Tuesday, 30 August 2011

Free Google Online Chat Support For Website and Blogs
STEP1
Go to the following site and create a badge as shown in the Picture
http://www.google.com/talk/service/badge/New



STEP2
Add the HTML code into the website or Blog To get an Online Chat

STEP 3
Get the chat screen

Executing Commands listed in a notepad

Friday, 26 August 2011

create the below command as  a .bat file

FOR /F  %%a  in (E:\test\command.txt) do %%a

Give the command file location from which the commands to be executed

Thats it ur done 

Passing Parameters To Batch File with Spaces and to Poweshell

Thursday, 25 August 2011

This Tutorial covers passing parameters to a batch file and passing parameter to powershell script.

# The Below is the screen shot of the cmd screen passing parameter to batch file



The Below it the screen shot of the bat file ps.bat
The Below is the Contents Of Powershell Script
The Below is the result which displays the dir for the folder given





Poweshell Bacics in Debugging

Wednesday, 24 August 2011

A Free Debugger called PowerGUI is available for Poweshell debugging.

After downloading open the powershell as administrator and type the following command to start debugging with the PowerGuI
Set-ExecutionPolicy RemoteSigned
Boom-- start using the debugger with intellisense

Dos Dir Command

Friday, 19 August 2011

dir /qDisplay the directory with the owner of the file.

eg.
03/18/2011  10:43 AM    <DIR>          MEDALLCORP\madhan      Charcoal.txt
03/18/2011  10:44 AM    <DIR>          MEDALLCORP\madhan      Colors.jpeg

dir /s
Display the files in the specified directory and all subdirectories





dir /s
Display the files in the specified directory and all subdirectories

dir /od
Displays files sorted by date dir /on sorts file in alphabetical order
dir /o-d
Displays file sorted by date descending order.













SQL String Functions

SQL String Functions

Sql string function is a built-in string function.
It perform an operation on a string input value and return a string or numeric value.
Below is All built-in Sql string function :
ASCII, NCHAR, SOUNDEX, CHAR, PATINDEX, SPACE,CHARINDEX, REPLACE, STR, DIFFERENCE, QUOTENAME,STUFF, LEFT, REPLICATE, SUBSTRING, LEN, REVERSE,UNICODE, LOWER, RIGHT, UPPER, LTRIM, RTRIM


Example SQL String Function - ASCII
- Returns the ASCII code value of a keyboard button and the rest etc (@,R,9,*) .
Syntax - ASCII ( character)SELECT ASCII('a') -- Value = 97
SELECT ASCII('b') -- Value = 98
SELECT ASCII('c') -- Value = 99
SELECT ASCII('A') -- Value = 65
SELECT ASCII('B') -- Value = 66
SELECT ASCII('C') -- Value = 67
SELECT ASCII('1') -- Value = 49
SELECT ASCII('2') -- Value = 50
SELECT ASCII('3') -- Value = 51
SELECT ASCII('4') -- Value = 52
SELECT ASCII('5') -- Value = 53 



Example SQL String Function - SPACE 
-Returns spaces in your SQL query (you can specific the size of space). 
Syntax - SPACE ( integer)
SELECT ('SQL') + SPACE(0) + ('TUTORIALS')
-- Value = SQLTUTORIALS
SELECT ('SQL') + SPACE(1) + ('TUTORIALS')
-- Value = SQL TUTORIALS 



Example SQL String Function - CHARINDEX
-Returns the starting position of a character string.
Syntax - CHARINDEX ( string1, string2 [ , start_location ] ) 
SELECT CHARINDEX('SQL', 'Well organized understand SQL tutorial') 

-- Value = 27SELECT CHARINDEX('SQL', 'Well organized understand SQL tutorial', 20) 
-- Value = 27SELECT CHARINDEX('SQL', 'Well organized understand SQL tutorial', 30)
-- Value = 0 (Because the index is count from 30 and above)


Example SQL String Function - REPLACE
-Replaces all occurrences of the string2 in the string1 with string3.
Syntax - REPLACE ( 'string1' , 'string2' , 'string3' )
SELECT REPLACE('All Function' , 'All', 'SQL')
-- Value = SQL Function


Example SQL String Function - QUOTENAME
-Returns a Unicode string with the delimiters added to make the input string a valid Microsoft® SQL Server™ delimited identifier.
Syntax - QUOTENAME ( 'string' [ , 'quote_character' ] ) 
SELECT QUOTENAME('Sql[]String')
-- Value = [Sql[]]String]


Example SQL String Function - STUFF
- Deletes a specified length of characters and inserts string at a specified starting index.
Syntax - STUFF ( string1 , startindex , length , string2 ) 

SELECT STUFF('SqlTutorial', 4, 6, 'Function')
-- Value = SqlFunctional
SELECT STUFF('GoodMorning', 5, 3, 'good')
-- Value = Goodgoodning


Example SQL String Function - LEFT
-Returns left part of a string with the specified number of characters.
Syntax - LEFT ( string , integer) 
SELECT LEFT('TravelYourself', 6) 
-- Value = Travel
SELECT LEFT('BeautyCentury',6) 
-- Value = Beauty


Example SQL String Function - RIGHT
-Returns right part of a string with the specified number of characters.
Syntax - RIGHT( string , integer)
SELECT RIGHT('TravelYourself', 6)-- Value = urself
SELECT RIGHT('BeautyCentury',6)-- Value = 
Century


Example SQL String Function - REPLICATE
-Repeats string for a specified number of times.

Syntax - REPLICATE (string, integer)SELECT REPLICATE('Sql', 2) 
-- Value = SqlSql


Example SQL String Function - SUBSTRING
-Returns part of a string.

Syntax - SUBSTRING ( string, startindex , length )
SELECT SUBSTRING('SQLServer', 4, 3) 

-- Value = Ser


Example SQL String Function - LEN
-Returns number of characters in a string.
Syntax - LEN( string) 
SELECT LEN('SQLServer')
-- Value = 
9


Example SQL String Function - REVERSE
-Returns reverse a string.Syntax - REVERSE( string)SELECT REVERSE('SQLServer') 

-- Value = revreSLQS


Example SQL String Function - UNICODE
-Returns Unicode standard integer value.
Syntax - UNICODE( char) 
SELECT UNICODE('SqlServer') 
-- Value = 83 (it take first character)
SELECT UNICODE('S')
-- Value = 
83


Example SQL String Function - LOWER
-Convert string to lowercase.Syntax - LOWER( string )SELECT LOWER('SQLServer') 

-- Value = sqlserver


Example SQL String Function - UPPER
-Convert string to Uppercase.
Syntax - UPPER( string ) 
SELECT UPPER('sqlserver') 
-- Value = SQLSERVER


Example SQL String Function - LTRIM
-Returns a string after removing leading blanks on Left side.
Syntax - LTRIM( string )SELECT LTRIM(' sqlserver')-- Value = 'sqlserver' (Remove left side space or blanks)



Example SQL String Function - RTRIM 
-Returns a string after removing leading blanks on Right side.

Syntax - RTRIM( string )SELECT RTRIM('SqlServer ')
-- Value = 'SqlServer' (Remove right side space or blanks)

Function to Parse AlphaNumeric Characters from String

CREATE FUNCTION dbo.UDF_ParseAlphaChars(@string VARCHAR(8000)
)
RETURNS VARCHAR(8000)AS
BEGIN
DECLARE 
@IncorrectCharLoc SMALLINTSET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string)WHILE @IncorrectCharLoc > 0BEGIN
SET 
@string = STUFF(@string, @IncorrectCharLoc, 1, '')SET @IncorrectCharLoc = PATINDEX('%[^0-9A-Za-z]%', @string)END
SET 
@string = @stringRETURN @stringENDGO

—-Test
SELECT dbo.UDF_ParseAlphaChars('ABC”_I+{D[]}4|:e;””5,<.F>/?6')GO

Result Set : ABCID4e5F6

Funtion to get Number Part of the Alphanumeric String

create function NoLetters(@number varchar(20)) returns varchar(20)

as

begin

declare @c int

set @c=65

while @c<65+26

begin

set @number=replace(@number,char(@c),'')

set @c=@c+1

end

return(@number)

end

Funtion to get Alphabet Parts of the Alphanumeric String

Alter function GetLetters(@string NVARCHAR(50))

RETURNS VARCHAR(20)

AS

BEGIN

DECLARE
@IncorrectCharLoc SMALLINT

SET @IncorrectCharLoc = PATINDEX('%[^A-Za-z]%', @string)

WHILE @IncorrectCharLoc > 0

BEGIN

SET
@string = STUFF(@string, @IncorrectCharLoc, 1, '')

SET @IncorrectCharLoc = PATINDEX('%[^A-Za-z]%', @string)

END

SET
@string = @string

RETURN @string



end

selectdbo.GetLetters('ABC_I+{D[4|:e;5,<.F>/?6')


output
ABCIDeF

Get Files in A folder which is modified on a particular day

Thursday, 18 August 2011

FORFILES /D 08/18/2011 /C "cmd /c echo @fname is new Today"
MM-DD-YYYY
FORFILES /D 08/18/2011 /C "cmd /c echo @fname is new Today"

FORFILES.exe (Resource Kit)
Select a file (or set of files) and execute a command on each file. Batch processing.
Syntax
      FORFILES [/p Path] [/m Mask] [/s] [/c Command] [/d [+ | -] {dd/MM/yyyy | dd}]  
Key
   /p Path      The Path to search  (default=current folder)
   /s           Recurse into sub-folders
   /C command   The command to execute for each file.
                Wrap the command string in double quotes.
                Default = "cmd /c echo @file"
                The Command variables listed below can also be used in the
                command string.
   /D date      Select files with a last modified date greater than or
                equal to (+), or less than or equal to (-),
                the specified date using the "dd/MM/yyyy" format;
                or selects files with a last modified date greater than
                or equal to (+) the current date plus "dd" days, or
                less than or equal to (-) the current date minus "dd" days.
                A valid "dd" number of days can be any number in
                the range of 0 - 32768.
                "+" is taken as default sign if not specified.
 Command Variables:
      @file    The name of the file.
      @fname   The file name without extension.               
      @ext     Only the extension of the file.                 
      @path    Full path of the file.
      @relpath Relative path of the file.         
      @isdir   Returns "TRUE" if a file type is a directory,
               and "FALSE" for files.
      @fsize   Size of the file in bytes.
      @fdate   Last modified date of the file.
      @ftime   Last modified time of the file.
  
   Internal CMD.exe commands must be preceded with "cmd /c".
  
   If ForFiles finds one or more matches if will return %errorlevel% =0
If ForFiles finds no matches if will return %errorlevel% =1 and will print "ERROR: No files found with the specified search criteria."
Examples:
Print a warning if the testfile is 5 days old or older:
C:\> forfiles /m testfile.txt /c "cmd /c echo file is too old" /d -5
Delete the testfile if it is is 5 days old or older:
C:\> forfiles /m testfile.txt /c "cmd /c Del testfile.txt " /d -5
Find .xls file that were last modified 30 days ago or longer
C:\> FORFILES /M *.xls /C "cmd /c echo @path was changed 30 days ago" /D -30
List the size of all .doc files:
C:\> FORFILES /S /M *.doc /C "cmd /c echo @fsize"
An alternative method of dealing with files older or newer than a specified date is to use ROBOCOPY

Exe To Windows Service

Wednesday, 17 August 2011


How to convert  an exe to a service?

How to create user defined function in windows?

How to create a PACS windows Service Using dcmtk storescp.exe ?

Steps

1.       Create a Service with your desired name

2.       Associate your  service to an exe in the registry

3.       Enjoy.

STEP 1:

i.                     Files required to create a windows service Instsrv.exe and Srvany.exe

ii.                   Download the files to Create a Service with your desired service name


iii.                  Paste the contents to a folder. Eg: C:\resourcetoolkit


iv.                 Open your cmd as an administrator


v.                   Location of the Instrv.exe  ServiceNameToBeCreated  Location of the Srvany.exe

(eg: C:\resourcetoolkit\Instsrv.exe MyDesiredServiceName C:\resourcetoolkit\Srvany.exe)

(eg: C:\resourcetoolkit\Instsrv.exe dcmtkpacs C:\resourcetoolkit\Srvany.exe)


vi.                 Now the Service has been created( check at services.msc)

STEP 2:

i.                     Open Run

ii.                   Type regedit (to  open registry editor)

iii.                  Navigate to that Service To Our Exe mapping location 
                HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<my service>
  

                         
iv.                 Create a New Key with the Name Parameters


v.                   Create a New String value inside that Parameters Folder


vi.                 Give the String value the name or rename it as Application (data type REG_SZ)

      vii.                Right click to modify that String Application Created

viii.              Give the location of the .exe  in the value data of Application


a.        Exe without parameters (eg.)

D:\dcmtk\bin\notepad.exe

b.      Exe with parameters as (eg.)

 D:\dcmtk\bin\storescp.exe -aet STORESCP  -su "" -fe “.dcm”  -od  F:\dcmtkpacsstorage 104

ix.                 That’s it

STEP 3

i.                     You have converted a exe to service successfully

ii.                   Have a Tea.

VMWARE, Windows Interview questions

Friday, 12 August 2011

XML Syntax

bat file with parameters



-- save the code as cool.bat
@echo on
set ConsoleAppLoc=%1
set dcmraw=%2
set seriesid=%3
set dcmcompressed=%4
IF NOT EXIST %dcmcompressed%%seriesid% mkdir %dcmcompressed%%seriesid%
FOR /R %dcmraw% %%G IN (*.dcm) DO %ConsoleAppLoc% %dcmraw%\%%~nxG %dcmcompressed%%seriesid%\%%~nxG
EXIT
-- call the bat file in the below format from command prompt
c:/>cool.bat parmeter1 parameter2 parameter3 parameter4




Batch File to Delete Files and Folders Based On Last Modified Date


@ECHO OFF
SET folderlocation=E:\DatabaseBackup
forfiles.exe /p %folderlocation% /s /m *.* /d -1 /c "cmd /c del @file"
pause
EXIT

Calling Stored Procedure From Command Prompt

Thursday, 11 August 2011




@ECHO OFF
set sqlserverinstance=192.168.1.2\sqlexpress
set serverusername=sa
set serverpassword=123
set DatabaseName=Madhan

Sqlcmd -S %sqlserverinstance% -U %serverusername% -P %serverpassword% -d %DatabaseName% -Q "exec SPNAME"

Batch File to Get Contents of a Folder

Wednesday, 10 August 2011

@ECHO OFF
set ConsoleAppLoc=D:\dcmtk\bin\dcmdjpeg.exe
set dcmraw=H:\dcmraw\series
set dcmcompressed=H:\dcmcompressed
FOR /R %dcmraw% %G IN (*.dcm) DO  %ConsoleAppLoc% %dcmraw%\%~nxG %dcmcompressed%\%~nxG
EXIT



@ECHO OFF
set ConsoleAppLoc=D:\dcmtk\bin\dcmdjpeg.exe
set dcmraw=H:\dcmraw\series
set seriesid=cool
set dcmcompressed=H:\dcmcompressed\
IF NOT EXIST %dcmcompressed%%seriesid% mkdir %dcmcompressed%%seriesid%
FOR /R %dcmraw% %G IN (*.dcm) DO  %ConsoleAppLoc% %dcmraw%\%~nxG %dcmcompressed%\%seriesid%\%~nxG
EXIT
 

Batch File Programming

Working With Variables

@ECHO OFF

set ConsoleAppLoc=D:\dcmtk\bin\dcmdjpeg.exe
set dcmraw=H:\dcmraw\series
set dcmcompressed=H:\dcmcompressed

ECHO %dcmraw%
ECHO %ConsoleAppLoc%
ECHO %dcmcompressed%

--- output will be
D:\dcmtk\bin\dcmdjpeg.exe
H:\dcmraw\series
H:\dcmcompressed

Dos Command

Command shell overview

The command shell is a separate software program that provides direct communication between the user and the operating system. The non-graphical command shell user interface provides the environment in which you run character-based applications and utilities. The command shell executes programs and displays their output on the screen by using individual characters similar to the MS-DOS command interpreter Command.com. The Windows XP command shell uses the command interpreter Cmd.exe, which loads applications and directs the flow of information between applications, to translate user input into a form that the operating system understands.
You can use the command shell to create and edit batch files (also called scripts) to automate routine tasks. For example, you can use scripts to automate the management of user accounts or nightly backups. You can also use the Windows Script Host, CScript.exe, to run more sophisticated scripts in the command shell. You can perform operations more efficiently by using batch files than you can by using the user interface. Batch files accept all commands that are available at the command line. For more information about batch files and scripting, see Using batch files
You can customize the command prompt window for easier viewing and to increase control over how you run programs. For more information about customizing the command prompt window, see To configure the command prompt

Using command syntax

Syntax appears in the order in which you must type a command and any parameters that follow it. The following example of the xcopy command illustrates a variety of syntax text formats:
xcopy Source [Destination] [/w] [/p] [/c] [/v] [/q] [/f] [/l] [/g] [/d[:mm-dd-yyyy]] [/u] [/i] [/s [/e]] [/t] [/k] [/r] [/h] [{/a|/m}] [/n] [/o] [/x] [/exclude:file1[+[file2]][+[file3]] [{/y|/-y}] [/z]
The following table explains how to interpret the different text formats.

Formatting legend

FormatMeaning
Italic
Information that the user must supply
Bold
Elements that the user must type exactly as shown
Ellipsis (...)
Parameter that can be repeated several times in a command line
Between brackets ([])
Optional items
Between braces ({}); choices separated by pipe (|). Example: {even|odd}
Set of choices from which the user must choose only one
Courier font
Code or program output

Using multiple commands and conditional processing symbols

You can run multiple commands from a single command line or script using conditional processing symbols. When you run multiple commands with conditional processing symbols, the commands to the right of the conditional processing symbol act based upon the results of the command to the left of the conditional processing symbol. For example, you might want to run a command only if the previous command fails. Or, you might want to run a command only if the previous command is successful.
You can use the special characters listed in the following table to pass multiple commands.
CharacterSyntaxDefinition
& [...]
command1 & command2
Use to separate multiple commands on one command line. Cmd.exe runs the first command, and then the second command.
&& [...]
command1 && command2
Use to run the command following && only if the command preceding the symbol is successful. Cmd.exe runs the first command, and then runs the second command only if the first command completed successfully.
|| [...]
command1 || command2
Use to run the command following || only if the command preceding || fails. Cmd.exe runs the first command, and then runs the second command only if the first command did not complete successfully (receives an error code greater than zero).
( ) [...]
(command1 & command2) 
Use to group or nest multiple commands.
; or ,
command1 parameter1;parameter2
Use to separate command parameters.

 

Note
The ampersand (&), pipe (|), and parentheses ( ) are special characters that must be preceded by the escape character (^) or quotation marks when you pass them as arguments.
If a command completes an operation successfully, it returns an exit code of zero (0) or no exit code. For more information about exit codes, see Microsoft Windows Resource Kits 

Nesting command shells

You can nest command shells within Cmd.exe by opening a new instance of Cmd.exe at the command prompt. By default, each instance of Cmd.exe inherits the environment of its parent Cmd.exe application. By nesting instances of Cmd.exe, you can make changes to the local environment without affecting the parent application of Cmd.exe. This allows you to preserve the original environment of Cmd.exe and return to it after you terminate the nested command shell. The changes you make in the nested command shell are not saved.
To nest a command shell, at the command prompt, type:
cmd
A message similar to the following appears:
Microsoft (R) Windows XP (TM)
(C) Copyright 1985-2001 Microsoft Corp.
To close the nested command shell, type exit.
You can localize changes even further in an instance of Cmd.exe (or in a script) by using the setlocal and endlocal commands. Setlocal creates a local scope and endlocal terminates the local scope. Any changes made within the setlocal and endlocal scope are discarded, thereby leaving the original environment unchanged. You can nest these two commands to a maximum of 32 levels. For more information about the setlocal and endlocal commands, see Setlocal and Endlocal

Using environment variables with Cmd.exe

The Cmd.exe command-shell environment is defined by variables that determine the behavior of the command shell and the operating system. You can define the behavior of the command-shell environment or the entire operating system environment by using two types of environment variables, system and local. System environment variables define the behavior of the global operating system environment. Local environment variables define the behavior of the environment of the current instance of Cmd.exe.
System environment variables are preset in the operating system and available to all Windows XP processes. Only users with administrative privileges can change system variables. These variables are most commonly used in logon scripts.
Local environment variables are only available when the user for whom they were created is logged on to the computer. Local variables set in the HKEY_CURRENT_USER hive are valid only for the current user, but define the behavior of the global operating system environment.
The following list describes the various types of variables in descending order of precedence:
1.
Built-in system variables
2.
System variables found in the HKEY_LOCAL_MACHINE hive
3.
Local variables found in the HKEY_CURRENT_USER hive
4.
All environment variables and paths set in the Autoexec.bat file
5.
All environment variables and paths set in a logon script (if present)
6.
Variables used interactively in a script or batch file
In the command shell, each instance of Cmd.exe inherits the environment of its parent application. Therefore, you can change the variables in the new Cmd.exe environment without affecting the environment of the parent application.
The following table lists the system and local environment variables for Windows XP.
VariableTypeDescription
%ALLUSERSPROFILE%
Local
Returns the location of the All Users Profile.
%APPDATA%
Local
Returns the location where applications store data by default.
%CD%
Local
Returns the current directory string.
%CMDCMDLINE%
Local
Returns the exact command line used to start the current Cmd.exe.
%CMDEXTVERSION%
System
Returns the version number of the current Command Processor Extensions.
%COMPUTERNAME% 
System
Returns the name of the computer.
%COMSPEC% 
System
Returns the exact path to the command shell executable.
%DATE% 
System
Returns the current date. Uses the same format as the date /t command. Generated by Cmd.exe. For more information about the datecommand, see Date
%ERRORLEVEL% 
System
Returns the error code of the most recently used command. A non zero value usually indicates an error.
%HOMEDRIVE% 
System
Returns which local workstation drive letter is connected to the user's home directory. Set based on the value of the home directory. The user's home directory is specified in Local Users and Groups.
%HOMEPATH% 
System
Returns the full path of the user's home directory. Set based on the value of the home directory. The user's home directory is specified in Local Users and Groups.
%HOMESHARE% 
System
Returns the network path to the user's shared home directory. Set based on the value of the home directory. The user's home directory is specified in Local Users and Groups.
%LOGONSEVER% 
Local
Returns the name of the domain controller that validated the current logon session.
%NUMBER_OF_PROCESSORS% 
System
Specifies the number of processors installed on the computer.
%OS% 
System
Returns the operating system name. Windows 2000 displays the operating system as Windows_NT.
%PATH%
System
Specifies the search path for executable files.
%PATHEXT%
System
Returns a list of the file extensions that the operating system considers to be executable.
%PROCESSOR_ARCHITECTURE% 
System
Returns the chip architecture of the processor. Values: x86, IA64.
%PROCESSOR_IDENTIFIER%
System
Returns a description of the processor.
%PROCESSOR_LEVEL% 
System
Returns the model number of the processor installed on the computer.
%PROCESSOR_REVISION%
System
Returns the revision number of the processor.
%PROMPT%
Local
Returns the command prompt settings for the current interpreter. Generated by Cmd.exe.
%RANDOM%
System
Returns a random decimal number between 0 and 32767. Generated by Cmd.exe.
%SYSTEMDRIVE%
System
Returns the drive containing the Windows XP root directory (that is, the system root).
%SYSTEMROOT% 
System
Returns the location of the Windows XP root directory.
%TEMP% and %TMP%
System and User
Returns the default temporary directories that are used by applications available to users who are currently logged on. Some applications require TEMP and others require TMP.
%TIME%
System
Returns the current time. Uses the same format as the time /t command. Generated by Cmd.exe. For more information about the timecommand, see Time
%USERDOMAIN%
Local
Returns the name of the domain that contains the user's account.
%USERNAME%
Local
Returns the name of the user who is currently logged on.
%USERPROFILE%
Local
Returns the location of the profile for the current user.
%WINDIR%
System
Returns the location of the operating system directory.

Setting environment variables

Use the set command to create, change, delete, or display environment variables. The set command alters variables in the current shell environment only.
To view a variable, at a command prompt, type:
set VariableName
To add a variable, at a command prompt, type:
set variablename=value
To delete a variable, at a command prompt, type:
set VariableName=
You can use most characters as variable values, including white space. If you use the special characters <, >, |, &, or ^, you must precede them with the escape character (^) or quotation marks. If you use quotation marks, they are included as part of the value because everything following the equal sign is taken as the value. Consider the following examples:
To create the variable value new&name, type:
set varname=new^&name
To create the variable value "new&name", type:
set varname="new&name"
If you type set varname=new&name at the command prompt, an error message similar to the following appears:
"'name' is not recognized as an internal or external command, operable program or batch file."
Variable names are not case-sensitive. However, set displays the variable exactly as you typed it. You can combine uppercase and lowercase letters in your variable names to make your code more readable (for example, UserName).

 

Note
The maximum individual environment variable size is 8192bytes.
The maximum total environment variable size for all variables, which includes variable names and the equal sign, is 65,536KB.

Substituting environment variable values

To enable the substitution of variable values at the command line or in scripts, enclose the variable name in percent signs (that is, %variablename%). By using percent signs, you ensure that Cmd.exe references the variable values instead of making a literal comparison. After you define variable values for a variable name, enclose the variable name in percent signs. Cmd.exe searches for all instances of the variable name and replaces it with the defined variable value. For example, if you create a script that contains different values (for example, user names) and you want to define the USERNAME environment variable for each user with these values, you can write one script using the variable USERNAME enclosed in percent signs. When you run this script, Cmd.exe replaces %USERNAME% with the variable values, which eliminates the need to perform this task manually for each user. Variable substitution is not recursive. Cmd.exe checks variables once. For more information about variable substitution, see For and Call
 

Blogger news

Blogroll

Most Reading

8.6/10