Environment Variables and string replacement for dos settings

Source: Internet
Author: User

Environment Variables and string replacement for dos settings

(1) Use the wmic command to set the system environment variables. It takes effect directly under xp. win7 needs to restart the computer or go to computer-> properties-> advanced-> environment variables. Click "OK ".

@ Echo off
Set regpath = HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Session Manager \ Environment
: Echo.
:: Echo ===================================================== ==========
: Echo installation settings
:: Echo ===================================================== ==========
: Echo.
: Set/p en = press enter to start installation! :
: Echo.
Set pwd = % cd %
: Reg add "% regpath %"/v "winrar"/d "% pwd % \ compact;"/f
: Echo.
: Echo new append environment variable path = % pwd % \ WinRAR
: For,/f, "skip = 4 token = 1, 2, *", % a, in, ('reg query "% regpath %"/v "path" '), do ,(
: Reg add "% regpath %"/v "path"/d "% c; % pwd % \ compact; % pwd % \ conf \ bin; % pwd % \ lib; "/f
::)
Wmic ENVIRONMENT where "name = 'path' and username = '<system>'" set VariableValue = "% path %; % pwd % \ compact; % pwd % \ conf \ bin; % pwd % \ lib ;"
Wmic ENVIRONMENT create name = "TESSDATA_PREFIX", username = "<system>", VariableValue = "% pwd % \ lib"
Echo.

(2) Replace the string. Note that you must replace the complex symbols in the string. You must use !!, The identifier must be added by setlocal enabledelayedexpansion and endlocal.

: Delete the environment variable of Path by replacing it with null.
Set p = % PATH %
Set pwd = % cd %
Set replace = % pwd % \ compact ^; % pwd % \ conf \ bin ^; % pwd % \ lib ^;
Setlocal enabledelayedexpansion
Set p =! P: % replace % =!
Wmic ENVIRONMENT where "name = 'path' and username = '<system>'" set VariableValue = "% p % ;"
Endlocal

(3) normally, replace string B in "aabbcc" with null.

Set a = "aabbcc"

Set B = % a: B = %

Echo % B %

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.