Archive

Posts Tagged ‘Shell’

Customizing Windows Run Command

2010/11/03 Leave a comment

Source: http://weblogs.asp.net/whaggard/archive/2004/04/11/111232.aspx

If you are like me you use windows run command all the time.  I hate using the mouse to point and click a shortcut on the start menu.  WIN-R are probably the two most over used keys on my keyboard.  After thinking about if awhile I hunted down how the run command works.  It turns out that it makes a call to ShellExecute, which I guess is not too surprising.  The next thing I wanted to find out was exactly how the commands are resolved. The following is an ordered list of how they are resolved ([1]):

  • The current working directory
  • The Windows directory (no subdirectories are searched)
  • The Windows\System32 directory
  • Directories listed in the PATH environment variable
  • The App Paths registry key

Naturally the next thing I wanted to do was customize existing commands or add new commands so I do not have to type as much (standard lazy approach).  After examining my options which were to put the executable in one of those paths (since it only locates executables and not shortcuts), modify the path environment variable or add a key to App Paths. The App Paths option seems to be the easiest and most flexible to me.  Here is a layout of what you need to do to add an App Paths entry ([1]):

HKEY_LOCAL_MACHINE

SOFTWARE

Microsoft

Windows

CurrentVersion

App Paths

file.exe

(Default) = The fully-qualified path and file name

Path = A semicolon-separated list of directories

DropTarget = {CLSID}

Disclaimer: Modifying the registry can cause serious problems that may require you to reinstall your operating system. I cannot guarantee that problems resulting from modifications to the registry can be solved. Use the information provided at your own risk.

The minimum needed to add a new entry is to add the key file.exe where file is the string you want to type into the run command and to add the Default entry which is the fully-qualified path to the file you want to execute. Note that even it the file you are going to reference isn’t an exe file you still need to put the .exe on the key. Here is a sample registry file that I created to add a shorter keyword for Internet Explorer:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ie.exe]

@=”C:\\Program Files\\Internet Explorer\\iexplore.exe”

After entering that entry into the registry I can simply type “ie” at the run command to open internet explorer.

Here is a list of some common commands I use at the run command:

  • cmd – Command prompt
  • winword – Microsoft Word
  • excel – Microsoft Excel
  • outlook – Microsoft Outlook
  • iexplore – Internet Explorer
  • firefox – Mozilla Firefox
  • notepad – Notepad
  • compmgmt.msc – Computer Management Console
  • control appwiz.cpl – Add/Remove programs dialog
  • mstsc – Microsoft Terminal Service Client
  • regedit – Registry Editor

If there is some program that I find myself using all the time I figure out what the run command is for it and if there is not a short easy one I add one to my App Paths as described above.  Does anyone else have some other common run commands they use?

Categories: Knowledge Tags:

RunAs + SystemRoot\system32 on a 64 Bits box

2010/07/01 Leave a comment

source:http://forums.techarena.in/windows-x64-edition/1189266.htm

Problem: From a 64bits machine (logged as a Domain User) i cannot run Qwsinta or Qprocess,… from a CMD (ran as Domain Admin)

Resolution:

 

When i launch cmd as admin (runas) i cannot find or use qwinsta qprocess rwinsta… even if im in %systemroot%\system32, here is the reason why:
“32-bit applications can access the native system directory by substituting
%windir%\Sysnative for %windir%\System32. WOW64 recognizes Sysnative as a
special alias used to indicate that the file system should not redirect the
access. The Sysnative is just a virtual directory, alias or pseudo-directory
that is not visible in Windows Explorer, directory listing, and does not
support native 64-bit processes that already been accessing the
%windir%\System32 folder. As such, Sysnative can only be used in file system
calls, and not in application’s user interface such as dialog box to open or
select folder.”

 

 

Application command name for Windows

2009/12/30 Leave a comment

http://social.technet.microsoft.com/wiki/contents/articles/application-command-name-for-windows.aspx

Application command name for Windows

If you encounter any problem launching some of the program, please try the following :

Press the Windows Key + R on your keyboard or click on Start > Start Search and type this command

Add/Remove Programs = appwiz.cpl

Administrative Tools = control admintools

Authorization Manager= azman.msc

Calculator = calc

Certificate Manager = certmgr.msc

Character Map = charmap

Check Disk Utility = chkdsk

Command Prompt = cmd.exe

Component Services = dcomcnfg

Computer Management = compmgmt.msc

Control Panel = control

Date and Time Properties = timedate.cpl

Defragment User Interface = dfrgui

Device Manager = devmgmt.msc

Direct X Troubleshooter = dxdiag

Disk Cleanup Utility = cleanmgr

Disk Management = diskmgmt.msc

Disk Parmelonion Manager = diskpart

Display Properties = control desktop or, alternatively desk.cpl

Ditilizer Calibration Tool = tabcal

Downloads = Downloads

DPI Scaling = dpiscaling

Driver Package Installer = dpinst

Driver Verifier Utility = verifier or, alternatively reset

DVD Player = dvdplay

Encryption File System = rekeywiz

Event Viewer = eventvwr.msc

Fax Cover Sheet Editor = fxscover

File Signature Verification Tool = sigverif

Folders Properties = control folders

Fonts = control fonts

Free Cell Card Game = freecell

Group Policy Editor = gpedit.msc

Iexpress Wizard = iexpress

Internet Explorer = iexplore

Internet Properties = inetcpl.cpl

IP Configuration = ipconfig.exe

iSCSI Initiator = iscsicpl

Keyboard Properties = control keyboard

Libraries = explorer or, alternatively Windows key + E

Local Security Settings = secpol.msc

Local Users and Groups = lusrmgr.msc

Logs You Out Of Windows = logoff

Microsoft Paint = mspaint.exe

Microsoft Support Diagnostic Tool = msdt

Mobility Center (mobile) = mblctr or, alternatively Windows key + X

Mouse Properties = control mouse

Mouse Properties = main.cpl

Network Connections = control netconnections

Network Connections = ncpa.cpl

Notepad = notepad

ODBC Data Source Administrator = odbcad32

On Screen Keyboard = osk or, alternatively Windows key + U

Optional Features Manager = optionalfeatures

Performance Monitor = perfmon.msc

Phone and Modem Options = telephon.cpl

Power Configuration = powercfg.cpl

Printer Migration = PrintBrmUi

Printers and Faxes = control printers

Private Character Editor = eudcedit

Regional Settings = intl.cpl

Registry Editor = regedit.exe

Remote Assistance = msra

Remote Desktop = mstsc

Resultant Set of Policy = rsop.msc

Scheduled Tasks = control schedtasks

Security Center = wscui.cpl

Services = services.msc

Shared Folders/MMC = fsmgmt.msc

Shuts Down Windows = shutdown

Snipping Tool = snippingtool

Sound Recorder = soundrecorder

Sound Volume = sndvol

Sounds and Audio = mmsys.cpl

Spider Solitare Card Game = spider

SQL Client Configuration = cliconfg

Sticky Note = StikyNot

Stored User Names and Passwords = credwiz

System Configuration Editor = sysedit

System Configuration Utility = msconfig

System File Checker Utility = sfc

System Information = msinfo32

System Properties = sysdm.cpl or, alternatively Windows key + Pause

Task Manager = taskmgr

Trusted Platform Module = TpmInit

User Accounts = netplwiz or, alternatively control userpasswords2

Utility Manager = utilman

Windows Activation = slui

Windows Backup Utility = sdclt

Windows Fax and Scan = wfs

Windows Firewall = firewall.cpl

Windows Firewall with Advanced Security = wf.msc

Windows Image Acquisition = wiaacmgr

Windows Magnifier = magnify

Windows Management Infrastructure = wmimgmt.msc

Windows Media Player = wmplayer

Windows Share Creation Wizard = shrpubw

Windows Standalong Update Manager = wusa

Windows System Security Tool = syskey

Windows Update App Manager = wuapp

Wordpad = write

Different shortcuts

These shortcuts let you access specific features and tools in Windows 7.

Action Center = rundll32.exe shell32.dll,Control_RunDLL wscui.cpl

Add Network Location = rundll32.exe shwebsvc.dll,AddNetPlaceRunDll

Add/Remove Programs = rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl

Add/Remove Programs = RunDll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,0

Add/Remove Windows Components = rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,2

Advanced Restore = sdclt.exe /restorewizardadmin

Aero (Transparency feature) Off = Rundll32.exe DwmApi #104

Aero (Transparency feature) On = Rundll32.exe DwmApi #102

Backup Location and Settings = sdclt.exe /configure

Content Advisor = RunDll32.exe msrating.dll,RatingSetupUI

Control Panel = RunDll32.exe shell32.dll,Control_RunDLL

Date and Time = rundll32.exe shell32.dll,Control_RunDLL timedate.cpl

Date and Time (Additional Clocks) = rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,1

Date and Time (Properties) = RunDll32.exe shell32.dll,Control_RunDLL timedate.cpl

Device Manager = RunDll32.exe devmgr.dll DeviceManager_Execute

Device Manager = rundll32.exe shell32.dll,Control_RunDLL hdwwiz.cpl

Display Settings = RunDll32.exe shell32.dll,Control_RunDLL access.cpl,,3

Folder Options = RunDll32.exe shell32.dll,Options_RunDLL 0

Folder Options (File Types) = RunDll32.exe shell32.dll,Control_Options 2

Folder Options (Search) = RunDll32.exe shell32.dll,Options_RunDLL 2

Folder Options (View) = RunDll32.exe shell32.dll,Options_RunDLL 7

Forgotten Password Wizard = RunDll32.exe keymgr.dll,PRShowSaveWizardExW

Hibernate = RunDll32.exe powrprof.dll,SetSuspendState

Indexing Options = control.exe srchadmin.dll

Keyboard Properties = RunDll32.exe shell32.dll,Control_RunDLL main.cpl @1

Lock Screen = RunDll32.exe user32.dll,LockWorkStation

Manage Wireless Networks = explorer.exe shell:::{1fa9085f-25a2-489b-85d4-86326eedcd87}

Map Network Drive = RunDll32.exe shell32.dll,SHHelpShortcuts_RunDLL Connect

Mouse Properties = RunDll32.exe shell32.dll,Control_RunDLL main.cpl @0

Network Connections = RunDll32.exe shell32.dll,Control_RunDLL ncpa.cpl

Notification Cache = rundll32.exe shell32.dll,Options_RunDLL 5

Open Control Panel (All Items) = explorer.exe shell:::{21ec2020-3aea-1069-a2dd-08002b30309d}

Pen and Touch Tablet PC (Settings) = rundll32.exe shell32.dll,Control_RunDLL tabletpc.cpl

Pen and Touch Tablet PC (Settings Flicks Tab) = rundll32.exe shell32.dll,Control_RunDLL tabletpc.cpl,,1

Pen and Touch Tablet PC (Settings Handwriting Tab) = rundll32.exe shell32.dll,Control_RunDLL tabletpc.cpl,,2

People Near Me = rundll32.exe shell32.dll,Control_RunDLL collab.cpl

People Near Me (Sign Up Tab) = rundll32.exe shell32.dll,Control_RunDLL collab.cpl,,1

Personalization = rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,2

Phone and Modem (Options) = rundll32.exe shell32.dll,Control_RunDLL telephon.cpl

Phone and Modem (Options Modems Tab) = rundll32.exe shell32.dll,Control_RunDLL telephon.cpl,,1

Phone and Modems (Options Advanced Tab) = rundll32.exe shell32.dll,Control_RunDLL telephon.cpl,,2

Power Options = rundll32.exe shell32.dll,Control_RunDLL powercfg.cpl

Power Options Modify Plan Settings = rundll32.exe shell32.dll,Control_RunDLL powercfg.cpl,,1

Regional Settings = RunDll32.exe shell32.dll,Control_RunDLL intl.cpl,,3

Restore Files = sdclt.exe /restorewizard

Screen Resolution = rundll32.exe shell32.dll,Control_RunDLL desk.cpl

ScreenSaver = rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1

Set Program Access and Computer Defaults = rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,3

Sound Control Playback Tab = rundll32.exe shell32.dll,Control_RunDLLmmsys.cpl

Sound Control Recording Tab = rundll32.exe shell32.dll,Control_RunDLLmmsys.cpl,,1

Sound Control Sounds Tab = rundll32.exe shell32.dll,Control_RunDLLmmsys.cpl,,2

Stored Usernames /Passwords = RunDll32.exe keymgr.dll,KRShowKeyMgr

System Properties = rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl

System Properties (Advanced Tab) = rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,3

System Properties (Hardware Tab) = rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,2

System Properties (Remote Tab) = rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,5

System Properties (System Protection Tab) = rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,4

System Properties (Advanced) RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,4

System Properties (Automatic Updates) = RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,5

Taskbar Properties = RunDll32.exe shell32.dll,Options_RunDLL 1

Unplug Eject Hardware = RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll

User Accounts = RunDll32.exe shell32.dll,Control_RunDLL nusrmgr.cpl

Welcome Center = rundll32.exe oobefldr.dll,ShowWelcomeCenter

Windows (About) = RunDll32.exe SHELL32.DLL,ShellAboutW

Windows Firewall = RunDll32.exe shell32.dll,Control_RunDLL firewall.cpl

Windows Firewall = rundll32.exe shell32.dll,Control_RunDLL firewall.cpl

Windows Security Center = RunDll32.exe shell32.dll,Control_RunDLL wscui.cpl

Wireless Network Setup = RunDll32.exe shell32.dll,Control_RunDLL NetSetup.cpl,@0,WNSW

Wireless Networks pop-up = rundll32.exe van.dll,RunVAN

Internet Explorer Advanced Settings

Delete All (Deeper Cleaning Including Add-on Data Deletion) = RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351

Delete All = RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255

Delete Cookies = RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

Delete Form Data = RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16

Delete History = RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

Delete Passwords = RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32

Delete Temporary Internet Files = RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

Categories: Ebook/Cheat Sheet, Shell Tags:

2009/11/05 Leave a comment

source:http://www.dostips.com/DtTipsStringManipulation.php#Snippets.MidString

Align Right Align text to the right i.e. to improve readability of number columns.
Left String Extract characters from the beginning of a string.
Map and Lookup Use Key-Value pair list to lookup and translate values.
Mid String Extract a Substring by Position.
Remove Remove a substring using string substitution.
Remove both Ends Remove the first and the last character of a string.
Remove Spaces Remove all spaces in a string via substitution.
Replace Replace a substring using string substitution.
Right String Extract characters from the end of a string.
Split String Split a String, Extract Substrings by Delimiters.
String Concatenation Add one string to another string.
Trim Left Trim spaces from the beginning of a string via “FOR” command.
Trim Quotes Remove surrounding quotes via FOR command.
Trim Right Trim spaces from the end of a string via substitution.
Trim Right Trim spaces from the end of a string via “FOR” command.

Align Right – Align text to the right i.e. to improve readability of number columns

Description: Add leading spaces to a string to make sure the output lines up. I.e. for variables no longer than 8 characters add 8 spaces at the front and then show only the last 8 characters of the variable.
Script:
1. 

2.

3.

4.

5.

6.

 

set x=3000 

set y=2

set x=        %x%

set y=        %y%

echo.X=%x:~-8%

echo.Y=%y:~-8%

 

Script Output:
DOS Script Ouput
X=    3000
Y=       2

 

TOP 

2008-01-01

Left String – Extract characters from the beginning of a string

Description: Similar to the Left function in VB a batch script can return a specified number of characters from the left side of a string by specifying a substring for an expansion given a position of 0 and a length using :~ while expanding a variable content. The example shows how to return the first 4 characters of a string.
Script:
1. 

2.

3.

4.

 

set str=politic 

echo.%str%

set str=%str:~0,4%

echo.%str%

 

Script Output:
DOS Script Ouput
politic
poli

 

TOP 

2008-01-01

Map and Lookup – Use Key-Value pair list to lookup and translate values

Description: This example shows an approach to map a name of a month into it`s corresponding two digit number. The key-value pairs are listed in the map variable separated by semicolon. Key and value itself are separated by one dash character. Same can be used to tranlate a day-of-the-week short string into a day-of-the-week long string by changing the map content only.
Script:
1. 

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

13.

14.

15.

16.

17.

18.

 

REM ---- Example 1: Translate name of month into two digit number ---- 

SET v=Mai

SET map=Jan-01;Feb-02;Mar-03;Apr-04;Mai-05;Jun-06;Jul-07;Aug-08;Sep-09;Oct-10;Nov-11;Dec-12

CALL SET v=%%map:*%v%-=%%

SET v=%v:;=&rem.%

ECHO.%v%

REM ---- Example 2: Translate abbreviation into full string ----

SET v=sun

set map=mon-Monday;tue-Tuesday;wed-Wednesday;thu-Thursday;fri-Friday;sat-Saturday;sun-Sunday

CALL SET v=%%map:*%v%-=%%

SET v=%v:;=&rem.%

ECHO.%v%

 

Script Output:
DOS Script Ouput
05
Sunday

 

TOP 

2008-01-01

Mid String – Extract a Substring by Position

Description: Similar to the Mid function in VB a batch script can return a specified number of characters from any position inside a string by specifying a substring for an expansion given a position and length using :~ while expanding a variable content. The example here shows how to extract the parts of a date.
Script:
1. 

2.

3.

4.

5.

 

echo.Date   : %date% 

echo.Weekday: %date:~0,3%

echo.Month  : %date:~4,2%

echo.Day    : %date:~7,2%

echo.Year   : %date:~10,4%

 

Script Output:
DOS Script Ouput
Date   : Sat 03/11/2006
Weekday: Sat
Month  : 03
Day    : 11
Year   : 2006

 

TOP 

2008-01-01

Remove – Remove a substring using string substitution

Description: The string substitution feature can also be used to remove a substring from another string. The example shown here removes all occurrences of “the ” from the string variable str.
Script:
1. 

2.

3.

4.

 

set str=the cat in the hat 

echo.%str%

set str=%str:the =%

echo.%str%

 

Script Output:
DOS Script Ouput
the cat in the hat
cat in hat

 

TOP 

2008-01-01

Remove both Ends – Remove the first and the last character of a string

Description: Using :~1,-1 within a variable expansion will remove the first and last character of the string.
Script:
1. 

2.

3.

4.

 

set str=politic 

echo.%str%

set str=%str:~1,-1%

echo.%str%

 

Script Output:
DOS Script Ouput
politic
oliti

 

TOP 

2008-01-01

Remove Spaces – Remove all spaces in a string via substitution

Description: This script snippet can be used to remove all spaces from a string.
Script:
1. 

2.

3.

4.

 

set str=      word       &rem 

echo."%str%"

set str=%str: =%

echo."%str%"

 

Script Output:
DOS Script Ouput
"      word       "
"word"

 

TOP 

2008-01-01

Replace – Replace a substring using string substitution

Description: To replace a substring with another string use the string substitution feature. The example shown here replaces all occurrences “teh” misspellings with “the” in the string variable str.
Script:
1. 

2.

3.

4.

 

set str=teh cat in teh hat 

echo.%str%

set str=%str:teh=the%

echo.%str%

 

Script Output:
DOS Script Ouput
teh cat in teh hat
the cat in the hat

 

TOP 

2008-01-01

Right String – Extract characters from the end of a string

Description: Similar to the Right function in VB a batch script can return a specified number of characters from the right side of a string by specifying a substring for an expansion given a negative position using :~ while expanding a variable content. The example shows how to return the last 4 characters of a string.
Script:
1. 

2.

3.

4.

 

set str=politic 

echo.%str%

set str=%str:~-4%

echo.%str%

 

Script Output:
DOS Script Ouput
politic
itic

 

TOP 

2008-01-01

Split String – Split a String, Extract Substrings by Delimiters

Description: Use the FOR command to split a string into parts. The example shows how to split a date variable into its parts.
Script:
1. 

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

 

echo.-- Split off the first date token, i.e. day of the week 

for /f %%a in ("%date%") do set d=%%a

echo.Date   : %date%

echo.d      : %d%

echo.

echo.-- Split the date into weekday, month, day, and year, using slash and space as delimiters

for /f "tokens=1,2,3,4 delims=/ " %%a in ("%date%") do set wday=%%a&set month=%%b&set day=%%c&set year=%%d

echo.Weekday: %wday%

echo.Month  : %month%

echo.Day    : %day%

echo.Year   : %year%

 

Script Output:
DOS Script Ouput
-- Split off the first date token, i.e. day of the week
Date   : Thu 12/02/2005
d      : Thu

-- Split the date into weekday, month, day, and year, using slash and space as delimiters
Weekday: Thu
Month  : 12
Day    : 02
Year   : 2005

 

TOP 

2008-02-26

String Concatenation – Add one string to another string

Description: This example shows how to add two strings in DOS.
Script:
1. 

2.

3.

4.

5.

6.

7.

8.

9.

10.

 

set "str1=Hello" 

set "str2=World"

set "str3=%str1%%str2%"

set "str4=%str1% %str2%"

set "str1=%str1% DOS %str2%"

echo.%str3%

echo.%str4%

echo.%str1%

 

Script Output:
DOS Script Ouput
HelloWorld
Hello World
Hello DOS World

 

TOP 

2008-04-28

Trim Left – Trim spaces from the beginning of a string via “FOR” command

Description: Use the FOR command to trim spaces at the beginning of a variable. In this example the variable to be trimmed is str.
Script:
1. 

2.

3.

4.

 

set str=               15 Leading spaces to truncate 

echo."%str%"

for /f "tokens=* delims= " %%a in ("%str%") do set str=%%a

echo."%str%"

 

Script Output:
DOS Script Ouput
"               15 Leading spaces to truncate"
"15 Leading spaces to truncate"

 

TOP 

2008-01-01

Trim Quotes – Remove surrounding quotes via FOR command

Description: The FOR command can be used to safely remove quotes surrounding a string. If the string does not have quotes then it will remain unchanged.
Script:
1. 

2.

3.

4.

 

set str="cmd politic" 

echo.%str%

for /f "useback tokens=*" %%a in ('%str%') do set str=%%~a

echo.%str%

 

Script Output:
DOS Script Ouput
"cmd politic"
cmd politic

 

TOP 

2008-01-01

Trim Right – Trim spaces from the end of a string via “FOR” command

Description: Trimming spaces at the end of a variable seems a little tricky. The following example shows how to use a FOR loop to trim up to 31 spaces from the end of a string. It assumes that Delayed Expansionis enabled.
Script:
1. 

2.

3.

4.

 

set str=15 Trailing Spaces to truncate               &rem 

echo."%str%"

for /l %%a in (1,1,31) do if "!str:~-1!"==" " set str=!str:~0,-1!

echo."%str%"

 

Script Output:
DOS Script Ouput
"15 Trailing Spaces to truncate               "
"15 Trailing Spaces to truncate"

 

TOP 

2008-01-01

Trim Right – Trim spaces from the end of a string via substitution

Description: Trimming spaces at the end of a variable seems a little tricky. The following example shows how to use the string substitution feature to trim up to 31 spaces from the end of a string. It assumes that the string to be trimmed never contains two hash “##” characters in a row.
Script:
1. 

2.

3.

4.

5.

6.

7.

8.

9.

10.

 

set str=15 Trailing Spaces to truncate               &rem 

echo."%str%"

set str=%str%##

set str=%str:                ##=##%

set str=%str:        ##=##%

set str=%str:    ##=##%

set str=%str:  ##=##%

set str=%str: ##=##%

set str=%str:##=%

echo."%str%"

 

Script Output:
DOS Script Ouput
"15 Trailing Spaces to truncate               "
"15 Trailing Spaces to truncate"
Categories: VBS/BATCH Tags: , ,