├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── question---get-support.md └── PULL_REQUEST_TEMPLATE.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Docs └── CHANGELOG.md ├── Images ├── DevCase_Banner.png ├── PATHS 01.png ├── PATHS 02.png ├── PATHS 03.png ├── Paypal_Donate.png ├── envato_circle.png ├── github_circle.png └── paypal_circle.png ├── LICENSE ├── README.md ├── SECURITY.md └── Solution ├── PATHS.sln └── PATHS ├── My Project ├── Application.Designer.vb ├── Application.myapp ├── AssemblyInfo.vb ├── Resources.Designer.vb ├── Resources.resx ├── Settings.Designer.vb └── Settings.settings ├── PATHS.vbproj ├── PATHS.vbproj.user ├── Resources ├── App.ico └── Help.txt ├── Tools ├── ConsoleUtil.vb ├── PathUtil.vb └── RegEdit.vb ├── UserInterface ├── HelpSection.vb └── Main.vb └── app.config /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: ElektroStudios 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | polar: # Replace with a single Polar username 14 | custom: https://codecanyon.net/item/elektrokit-class-library-for-net/19260282 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a bug report to help us improve 4 | title: "[BUG] Write the title here" 5 | labels: '' 6 | assignees: ElektroStudios 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the problem is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Actual behavior** 24 | A clear and concise description of the actual behavior that you observed. 25 | 26 | **Screenshots** 27 | If applicable, add screenshots to help explain your problem. 28 | 29 | **Environment (please complete the following information If applicable):** 30 | - OS: [e.g. Microsoft Windows 10 22H2 x64] 31 | - Program Version: [e.g. v1.0 x64] 32 | 33 | **Additional context** 34 | Add any other context about the problem here. 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FEATURE] Write the title here" 5 | labels: '' 6 | assignees: ElektroStudios 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question---get-support.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question / Get Support 3 | about: Ask any question you have in mind related to this project 4 | title: "[QUESTION] Write the title here" 5 | labels: '' 6 | assignees: ElektroStudios 7 | 8 | --- 9 | 10 | **Question** 11 | 12 | Please provide a clear and concise question. 13 | 14 | **Background** 15 | 16 | Briefly explain the context or background related to your question. 17 | 18 | **Attempts** 19 | 20 | Describe any attempts or solutions you have already tried. 21 | 22 | **Expected Outcome** 23 | 24 | What do you hope to achieve or understand from asking this question? 25 | 26 | **Additional Information** 27 | 28 | Include any additional information that may be relevant to your question. 29 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Please include a summary of the changes and the related issue. Also include relevant motivation and context. 4 | 5 | Fixes # (issue) 6 | 7 | ## Type of change 8 | 9 | Please delete options that are not relevant. 10 | 11 | - [ ] Bug fix (non-breaking change which fixes an issue) 12 | - [ ] New feature (non-breaking change which adds functionality) 13 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 14 | - [ ] This change requires a documentation update 15 | 16 | # How Has This Been Tested? 17 | 18 | Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. 19 | 20 | # Checklist: 21 | 22 | Please delete options that are not relevant. 23 | 24 | - [ ] I have performed a self-review of my code 25 | - [ ] I have commented my code, particularly in hard-to-understand areas 26 | - [ ] I have made corresponding changes to the documentation 27 | - [ ] My changes generate no new warnings 28 | - [ ] I have added tests that prove my fix is effective or that my feature works -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | . 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## 💪 Contributing 2 | 3 | Your contribution is highly appreciated!. If you have any ideas, suggestions, or encounter issues, feel free to open an issue.. 4 | 5 | Your input helps make this Work better for everyone. Thank you for your support! 🚀 6 | 7 | ## 💰 Beyond Contribution 8 | 9 | This work is distributed for educational purposes and without any profit motive. However, if you find value in my efforts and wish to support and motivate my ongoing work, you may consider contributing financially through the following options: 10 | 11 | - ### Paypal: 12 | You can donate any amount you like via **Paypal** by clicking on this button: 13 | 14 | [![Donation Account](Images/Paypal_Donate.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=E4RQEV6YF5NZY) 15 | 16 | - ### Envato Market: 17 | If you are a .NET developer, you may want to explore '**DevCase Class Library for .NET**', a huge set of APIs that I have on sale. 18 | Almost all reusable code that you can find across my works is condensed, refined and provided through DevCase Class Library. 19 | 20 | Check out the product: 21 | 22 | [![DevCase Class Library for .NET](Images/DevCase_Banner.png)](https://codecanyon.net/item/elektrokit-class-library-for-net/19260282) 23 | 24 | **Your support means the world to me! Thank you for considering it!** 👍 -------------------------------------------------------------------------------- /Docs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # PATHS Change Log 📋 2 | 3 | ## v1.4 (2024) *(current)* 🆕 4 | #### 🌟 Improvements: 5 | • Source-code upgraded to .NET Framework 4.8 6 | • Syntax usage (switch names) and syntax examples has been reworked. 7 | 8 | ## v1.1 to v1.3 (2019) 🔄 9 | *Change log information not available* 10 | 11 | ## v1.0 (2014) 🔄 12 | Initial Release. -------------------------------------------------------------------------------- /Images/DevCase_Banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment/a315d8166192db04e3e72e1cd6cc255ddbc4e352/Images/DevCase_Banner.png -------------------------------------------------------------------------------- /Images/PATHS 01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment/a315d8166192db04e3e72e1cd6cc255ddbc4e352/Images/PATHS 01.png -------------------------------------------------------------------------------- /Images/PATHS 02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment/a315d8166192db04e3e72e1cd6cc255ddbc4e352/Images/PATHS 02.png -------------------------------------------------------------------------------- /Images/PATHS 03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment/a315d8166192db04e3e72e1cd6cc255ddbc4e352/Images/PATHS 03.png -------------------------------------------------------------------------------- /Images/Paypal_Donate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment/a315d8166192db04e3e72e1cd6cc255ddbc4e352/Images/Paypal_Donate.png -------------------------------------------------------------------------------- /Images/envato_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment/a315d8166192db04e3e72e1cd6cc255ddbc4e352/Images/envato_circle.png -------------------------------------------------------------------------------- /Images/github_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment/a315d8166192db04e3e72e1cd6cc255ddbc4e352/Images/github_circle.png -------------------------------------------------------------------------------- /Images/paypal_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment/a315d8166192db04e3e72e1cd6cc255ddbc4e352/Images/paypal_circle.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2024 ElektroStudios 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 16 | 17 | # PATHS 18 | 19 | ### A command-line application to manage (add, remove or clean) the PATH and PATHEXT environment variables. 20 | 21 | ------------------ 22 | 23 | ## 🖼️ Screenshots 24 | 25 | ![](Images/PATHS%2001.png) 26 | 27 | ![](Images/PATHS%2002.png) 28 | 29 | ![](Images/PATHS%2003.png) 30 | 31 | ## 📝 Requirements 32 | 33 | - Microsoft Windows OS. 34 | 35 | ## 🤖 Getting Started 36 | 37 | Download the latest release by clicking [here](https://github.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment/releases/latest). 38 | 39 | ### Syntax 40 | 41 | PATHS.exe /OPTIONS [DIRECTORY PATH or FILE EXTENSION or ENTRY INDEX] 42 | 43 | ### Switches 44 | 45 | /L (or) /List | Lists the PATH entries. 46 | /E (or) /Export | Exports PATH and PATHEXT entries to a registry script file. 47 | /C (or) /Clean | Clean duplicates and missing directory paths in PATH and PATHEXT. 48 | /R (or) /Restore | Restores the PATH entries to Windows defaults. 49 | | 50 | /Add -User | Adda a directory to current user's PATH. 51 | /Add -Machine | Adds a directory to local machine PATH. 52 | /A (or) /Add | Adds a directory to current user's and local machine PATHs. 53 | | 54 | /Del -User | Deletes a directory from current user's PATH. 55 | /Del -Machine | Deletes a directory from local machine PATH. 56 | /D (or) /Del | Deletes a directory from current user's and local machine PATHs. 57 | | 58 | /AddExt -User | Adds a file extension to current user's PATHEXT. 59 | /AddExt -Machine | Adds a file extension to local machine PATHEXT. 60 | /AddExt | Adds a file extension to current user's and local machine PATHEXTs. 61 | | 62 | /DelExt -User | Deletes a file extension from current user's PATHEXT. 63 | /DelExt -Machine | Deletes a file extension from local machine PATHEXT. 64 | /DelExt | Deletes a file extension from current user's and local machine PATHEXTs. 65 | | 66 | /? (or) /Help | Shows this help. 67 | 68 | ### Switch value types 69 | 70 | Note: You can list all the entry indices using command: PATHS.exe /List 71 | 72 | /Del -User (Directory Path or Entry Index) 73 | /Del -Machine (Directory Path or Entry Index) 74 | 75 | /AddExt -User (File Extension) 76 | /AddExt -Machine (File Extension) 77 | 78 | /DelExt -User (File Extension) 79 | /DelExt -Machine (File Extension) 80 | 81 | ### Usage examples 82 | 83 | PATHS.exe /List 84 | (Lists the entries of PATH and PATHEXT) 85 | 86 | PATHS.exe /Clean 87 | (Clean duplicates and missing directory paths in PATH and PATHEXT) 88 | 89 | PATHS.exe /Restore 90 | (Restores the PATH and PATHEXT to Windows defaults) 91 | 92 | PATHS.exe /Export "C:\Registry File.reg" 93 | (Exports the PATH and PATHEXT entries to the specified registry script file) 94 | 95 | PATHS.exe /Add -User "C:\Directory" 96 | (Adds a directory with name "C:\Directory" to current user's PATH) 97 | 98 | PATHS.exe /Add -Machine "C:\Directory" 99 | (Adds a directory with name "C:\Directory" to local machine PATH) 100 | 101 | PATHS.exe /Add "C:\Directory" 102 | (Adds a directory with name "C:\Directory" to current user's and local machine PATHs) 103 | 104 | PATHS.exe /Del -User "C:\Directory" 105 | (Deletes any directory with name "C:\Directory" from current user's PATH) 106 | 107 | PATHS.exe /Del -Machine "C:\Directory" 108 | (Deletes any directory with name "C:\Directory" from local machine PATH) 109 | 110 | PATHS.exe /Del "C:\Directory" 111 | (Deletes any directory with name "C:\Directory" from current user's and local machine PATHs) 112 | 113 | PATHS.exe /Del -User 5 114 | (Deletes the entry with index 5 from current user's PATH) 115 | 116 | PATHS.exe /Del -Machine 5 117 | (Deletes the entry with index 5 from local machine PATH) 118 | 119 | PATHS.exe /AddExt -User ".test" 120 | (Adds a file extension with name ".test" to current user's PATHEXT) 121 | 122 | PATHS.exe /AddExt -Machine ".test" 123 | (Adds a file extension with name ".test" to local machine PATHEXT) 124 | 125 | PATHS.exe /AddExt ".test" 126 | (Adds a file extension with name ".test" to current user's and local machine PATHEXTs) 127 | 128 | PATHS.exe /DelExt -User ".test" 129 | (Deletes any file extension with name ".test" from current user's PATHEXT) 130 | 131 | PATHS.exe /DelExt -Machine ".test" 132 | (Deletes any file extension with name ".test" from local machine PATHEXT) 133 | 134 | PATHS.exe /DelExt ".test" 135 | (Deletes any file extension with name ".test" from current user's and local machine PATHEXTs) 136 | 137 | ## 🔄 Change Log 138 | 139 | Explore the complete list of changes, bug fixes, and improvements across different releases by clicking [here](/Docs/CHANGELOG.md). 140 | 141 | ## ⚠️ Disclaimer: 142 | 143 | This Work (the repository and the content provided in) is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Work or the use or other dealings in the Work. 144 | 145 | ## 💪 Contributing 146 | 147 | Your contribution is highly appreciated!. If you have any ideas, suggestions, or encounter issues, feel free to open an issue by clicking [here](https://github.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment/issues/new/choose). 148 | 149 | Your input helps make this Work better for everyone. Thank you for your support! 🚀 150 | 151 | ## 💰 Beyond Contribution 152 | 153 | This work is distributed for educational purposes and without any profit motive. However, if you find value in my efforts and wish to support and motivate my ongoing work, you may consider contributing financially through the following options: 154 | 155 |

156 |

157 |

__________________

158 |

Becoming my sponsor on Github:

159 |

You can show me your support by clicking here,
contributing any amount you prefer, and unlocking rewards!

160 |

161 | 162 |

163 |

__________________

164 |

Making a Paypal Donation:

165 |

You can donate to me any amount you like via Paypal by clicking here.

166 |

167 | 168 |

169 |

__________________

170 |

Purchasing software of mine at Envato's Codecanyon marketplace:

171 |

If you are a .NET developer, you may want to explore 'DevCase Class Library for .NET',
a huge set of APIs that I have on sale. Check out the product by clicking here

It also contains all piece of reusable code that you can find across the source code of my open source works.

172 |

173 | 174 |

Your support means the world to me! Thank you for considering it! 👍

175 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | To report vulnerabilities, please go to the Issues section and open a new ticket to get support. 6 | 7 | You can expect an update on your report within few days to weeks, although this may vary depending on the severity and complexity of the reported vulnerability. 8 | 9 | After submitting a vulnerability, you can expect one of the following responses: 10 | - If the vulnerability is accepted, actions will be taken to address it, and updates on the progress will be provided. 11 | - If the vulnerability is rejected, clear reasons will be provided, along with, if possible, suggestions for addressing any misunderstandings or errors in the report. 12 | -------------------------------------------------------------------------------- /Solution/PATHS.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "PATHS", "PATHS\PATHS.vbproj", "{9E0301C2-326E-4B61-B782-64785950D4E9}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {9E0301C2-326E-4B61-B782-64785950D4E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {9E0301C2-326E-4B61-B782-64785950D4E9}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {9E0301C2-326E-4B61-B782-64785950D4E9}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {9E0301C2-326E-4B61-B782-64785950D4E9}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Solution/PATHS/My Project/Application.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | -------------------------------------------------------------------------------- /Solution/PATHS/My Project/Application.myapp: -------------------------------------------------------------------------------- 1 |  2 | 3 | false 4 | false 5 | 0 6 | true 7 | 0 8 | 2 9 | true 10 | 11 | -------------------------------------------------------------------------------- /Solution/PATHS/My Project/AssemblyInfo.vb: -------------------------------------------------------------------------------- 1 | Imports System.Resources 2 | 3 | Imports System 4 | Imports System.Reflection 5 | Imports System.Runtime.InteropServices 6 | 7 | ' General Information about an assembly is controlled through the following 8 | ' set of attributes. Change these attribute values to modify the information 9 | ' associated with an assembly. 10 | 11 | ' Review the values of the assembly attributes 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 'The following GUID is for the ID of the typelib if this project is exposed to COM 23 | 24 | 25 | ' Version information for an assembly consists of the following four values: 26 | ' 27 | ' Major Version 28 | ' Minor Version 29 | ' Build Number 30 | ' Revision 31 | ' 32 | ' You can specify all the values or you can default the Build and Revision Numbers 33 | ' by using the '*' as shown below: 34 | ' 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Solution/PATHS/My Project/Resources.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | Imports System 15 | 16 | Namespace My.Resources 17 | 18 | 'This class was auto-generated by the StronglyTypedResourceBuilder 19 | 'class via a tool like ResGen or Visual Studio. 20 | 'To add or remove a member, edit your .ResX file then rerun ResGen 21 | 'with the /str option, or rebuild your VS project. 22 | ''' 23 | ''' A strongly-typed resource class, for looking up localized strings, etc. 24 | ''' 25 | _ 29 | Friend Module Resources 30 | 31 | Private resourceMan As Global.System.Resources.ResourceManager 32 | 33 | Private resourceCulture As Global.System.Globalization.CultureInfo 34 | 35 | ''' 36 | ''' Returns the cached ResourceManager instance used by this class. 37 | ''' 38 | _ 39 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager 40 | Get 41 | If Object.ReferenceEquals(resourceMan, Nothing) Then 42 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("PATHS.Resources", GetType(Resources).Assembly) 43 | resourceMan = temp 44 | End If 45 | Return resourceMan 46 | End Get 47 | End Property 48 | 49 | ''' 50 | ''' Overrides the current thread's CurrentUICulture property for all 51 | ''' resource lookups using this strongly typed resource class. 52 | ''' 53 | _ 54 | Friend Property Culture() As Global.System.Globalization.CultureInfo 55 | Get 56 | Return resourceCulture 57 | End Get 58 | Set 59 | resourceCulture = value 60 | End Set 61 | End Property 62 | 63 | ''' 64 | ''' Looks up a localized string similar to 65 | ''' ::::::::: ::: ::::::::::: ::: ::: :::::::: 66 | ''' :+: :+: :+: :+: :+: :+: :+: :+: :+: 67 | ''' +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ 68 | ''' +#++:++#+ +#++:++#++: +#+ +#++:++#++ +#++:++#++ 69 | ''' +#+ +#+ +#+ +#+ +#+ +#+ +#+ 70 | ''' #+# #+# #+# #+# #+# #+# #+# #+# 71 | ''' ### ### ### ### ### ### ######## v1.2 72 | ''' 73 | ''' 74 | ''' ------------------------------------------------------>>>> 75 | ''' 76 | ''' Application Author....: Elektro 77 | ''' A [rest of string was truncated]";. 78 | ''' 79 | Friend ReadOnly Property Help() As String 80 | Get 81 | Return ResourceManager.GetString("Help", resourceCulture) 82 | End Get 83 | End Property 84 | End Module 85 | End Namespace 86 | -------------------------------------------------------------------------------- /Solution/PATHS/My Project/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\Help.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 123 | 124 | -------------------------------------------------------------------------------- /Solution/PATHS/My Project/Settings.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | 15 | Namespace My 16 | 17 | _ 20 | Partial Friend NotInheritable Class MySettings 21 | Inherits Global.System.Configuration.ApplicationSettingsBase 22 | 23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) 24 | 25 | #Region "My.Settings Auto-Save Functionality" 26 | #If _MyType = "WindowsForms" Then 27 | Private Shared addedHandler As Boolean 28 | 29 | Private Shared addedHandlerLockObject As New Object 30 | 31 | _ 32 | Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) 33 | If My.Application.SaveMySettingsOnExit Then 34 | My.Settings.Save() 35 | End If 36 | End Sub 37 | #End If 38 | #End Region 39 | 40 | Public Shared ReadOnly Property [Default]() As MySettings 41 | Get 42 | 43 | #If _MyType = "WindowsForms" Then 44 | If Not addedHandler Then 45 | SyncLock addedHandlerLockObject 46 | If Not addedHandler Then 47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings 48 | addedHandler = True 49 | End If 50 | End SyncLock 51 | End If 52 | #End If 53 | Return defaultInstance 54 | End Get 55 | End Property 56 | End Class 57 | End Namespace 58 | 59 | Namespace My 60 | 61 | _ 64 | Friend Module MySettingsProperty 65 | 66 | _ 67 | Friend ReadOnly Property Settings() As Global.PATHS.My.MySettings 68 | Get 69 | Return Global.PATHS.My.MySettings.Default 70 | End Get 71 | End Property 72 | End Module 73 | End Namespace 74 | -------------------------------------------------------------------------------- /Solution/PATHS/My Project/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Solution/PATHS/PATHS.vbproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {9E0301C2-326E-4B61-B782-64785950D4E9} 8 | Exe 9 | PATHS.UserInterface.Main 10 | PATHS 11 | PATHS 12 | 512 13 | Console 14 | v4.8 15 | 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | true 22 | true 23 | bin\Debug\ 24 | PATHS.xml 25 | 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 26 | false 27 | 28 | 29 | AnyCPU 30 | Full 31 | true 32 | true 33 | true 34 | bin\Release\ 35 | PATHS.xml 36 | 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 37 | true 38 | false 39 | 40 | 41 | On 42 | 43 | 44 | Binary 45 | 46 | 47 | Off 48 | 49 | 50 | On 51 | 52 | 53 | Resources\App.ico 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | True 77 | Application.myapp 78 | True 79 | 80 | 81 | True 82 | True 83 | Resources.resx 84 | 85 | 86 | True 87 | Settings.settings 88 | True 89 | 90 | 91 | 92 | 93 | 94 | 95 | VbMyResourcesResXFileCodeGenerator 96 | Resources.Designer.vb 97 | My.Resources 98 | Designer 99 | 100 | 101 | 102 | 103 | 104 | MyApplicationCodeGenerator 105 | Application.Designer.vb 106 | 107 | 108 | SettingsSingleFileGenerator 109 | My 110 | Settings.Designer.vb 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 125 | -------------------------------------------------------------------------------- /Solution/PATHS/PATHS.vbproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ProjectFiles 5 | 6 | -------------------------------------------------------------------------------- /Solution/PATHS/Resources/App.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment/a315d8166192db04e3e72e1cd6cc255ddbc4e352/Solution/PATHS/Resources/App.ico -------------------------------------------------------------------------------- /Solution/PATHS/Resources/Help.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment/a315d8166192db04e3e72e1cd6cc255ddbc4e352/Solution/PATHS/Resources/Help.txt -------------------------------------------------------------------------------- /Solution/PATHS/Tools/ConsoleUtil.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Author : Elektro 3 | ' Assembly : HelpSection 4 | ' Modified : 09-April-2015 5 | ' *********************************************************************** 6 | ' 7 | ' Copyright (c) Elektro Studios. All rights reserved. 8 | ' 9 | ' *********************************************************************** 10 | 11 | #Region " Option Statements " 12 | 13 | Option Explicit On 14 | Option Strict On 15 | Option Infer Off 16 | 17 | #End Region 18 | 19 | Namespace Tools 20 | 21 | ''' 22 | ''' Contains related Console tools. 23 | ''' 24 | Public NotInheritable Class ConsoleUtil 25 | 26 | ' Name.......: Write Colored Text 27 | ' Author.....: Elektro 28 | ' Description: Methods to write colorized strings. 29 | ' Last Update: 05/01/2014 30 | ' References.: LINQ 31 | ' Indications: Use *F##* as the ForeColor beginning delimiter, use *-F* to restore the console forecolor. 32 | ' Use *B##* as the BackColor beginning delimiter, use *-B* to restore the console BackColor. 33 | ' 34 | ' Example Usages: 35 | ' 36 | ' WriteColoredText( " Hello World! ", ConsoleColor.Blue, ConsoleColor.Blue) 37 | ' WriteColoredTextLine(" Hello World! ", ConsoleColor.Magenta, ConsoleColor.Gray) 38 | ' WriteColoredTextLine(" Hello World! ", Nothing, Nothing) 39 | ' 40 | ' WriteColoredText("*F10*Hello *F14*World!*-F*", {"*"c}) 41 | ' WriteColoredTextLine("{B15}{F12} Hello World! {-F}{-B}", {"{"c, "}"c}) 42 | ' WriteColoredTextLine(String.Format("*B15**F12* {0} *F0*{1} *-F**-B*", "Hello", "World!"), {"*"c}) 43 | 44 | ''' 45 | ''' Writes colored text on the Console. 46 | ''' 47 | ''' Indicates the color-delimited text to parse and then write. 48 | ''' Indicates a set of (1 or 2) delimiters to parse a color-delimited string. 49 | Public Shared Sub WriteColoredText(ByVal text As String, 50 | ByVal delimiters As Char()) 51 | 52 | ' Store the current console colors to restore them later. 53 | Dim currentForegroundColor As ConsoleColor = Console.ForegroundColor 54 | Dim currentBackgroundColor As ConsoleColor = Console.BackgroundColor 55 | 56 | ' Split the string to retrieve and parse the color-delimited strings. 57 | Dim stringParts As String() = 58 | text.Split(delimiters, StringSplitOptions.RemoveEmptyEntries) 59 | 60 | ' Parse the string parts 61 | For Each part As String In stringParts 62 | 63 | If part.ToUpper Like "F#" _ 64 | OrElse part.ToUpper Like "F##" Then ' Change the ForeColor. 65 | 66 | Console.ForegroundColor = DirectCast(CInt(part.Substring(1)), ConsoleColor) 67 | 68 | ElseIf part.ToUpper Like "B#" _ 69 | OrElse part.ToUpper Like "B##" Then ' Change the BackgroundColor. 70 | 71 | Console.BackgroundColor = DirectCast(CInt(part.Substring(1)), ConsoleColor) 72 | 73 | ElseIf part.ToUpper Like "-F" Then ' Restore the original Forecolor. 74 | 75 | Console.ForegroundColor = currentForegroundColor 76 | 77 | ElseIf part.ToUpper Like "-B" Then ' Restore the original BackgroundColor. 78 | 79 | Console.BackgroundColor = currentBackgroundColor 80 | 81 | Else ' String part is not a delimiter so we can print it. 82 | 83 | Console.Write(part) 84 | 85 | End If 86 | 87 | Next part 88 | 89 | ' Finish by restoring the original console colors. 90 | Console.BackgroundColor = currentBackgroundColor 91 | Console.ForegroundColor = currentForegroundColor 92 | 93 | End Sub 94 | 95 | ''' 96 | ''' Writes colored text on the Console. 97 | ''' 98 | ''' Indicates the text to write. 99 | ''' Indicates the text color. 100 | ''' Indicates the background color. 101 | Public Shared Sub WriteColoredText(ByVal text As String, 102 | ByVal foreColor As ConsoleColor, 103 | ByVal backColor As ConsoleColor) 104 | 105 | ' Store the current console colors to restore them later. 106 | Dim currentForegroundColor As ConsoleColor = Console.ForegroundColor 107 | Dim currentBackgroundColor As ConsoleColor = Console.BackgroundColor 108 | 109 | ' Set the new temporal console colors. 110 | Console.ForegroundColor = If(foreColor = Nothing, currentForegroundColor, foreColor) 111 | Console.BackgroundColor = If(backColor = Nothing, currentBackgroundColor, backColor) 112 | 113 | ' Print the text. 114 | Console.Write(text) 115 | 116 | ' Finish by restoring the original console colors. 117 | Console.ForegroundColor = currentForegroundColor 118 | Console.BackgroundColor = currentBackgroundColor 119 | 120 | End Sub 121 | 122 | ''' 123 | ''' Writes colored text on the Console and adds an empty line at the end. 124 | ''' 125 | ''' Indicates the color-delimited text to parse and then write. 126 | ''' Indicates a set of (1 or 2) delimiters to parse a color-delimited string. 127 | Public Shared Sub WriteColoredTextLine(ByVal text As String, 128 | ByVal delimiters As Char()) 129 | 130 | WriteColoredText(text & Environment.NewLine, delimiters) 131 | 132 | End Sub 133 | 134 | ''' 135 | ''' Writes colored text on the Console and adds an empty line at the end. 136 | ''' 137 | ''' Indicates the color-delimited text to parse and then write. 138 | ''' Indicates the text color. 139 | ''' Indicates the background color. 140 | Public Shared Sub WriteColoredTextLine(ByVal text As String, 141 | ByVal foreColor As ConsoleColor, 142 | ByVal backColor As ConsoleColor) 143 | 144 | WriteColoredText(text & Environment.NewLine, foreColor, backColor) 145 | 146 | End Sub 147 | 148 | End Class 149 | 150 | End Namespace -------------------------------------------------------------------------------- /Solution/PATHS/Tools/PathUtil.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Author : Elektro 3 | ' Modified : 11-June-2015 4 | ' *********************************************************************** 5 | ' 6 | ' Copyright (c) Elektro Studios. All rights reserved. 7 | ' 8 | ' *********************************************************************** 9 | 10 | #Region " Option Statements " 11 | 12 | Option Explicit On 13 | Option Strict On 14 | Option Infer Off 15 | 16 | #End Region 17 | 18 | #Region " Path Util " 19 | 20 | Namespace Tools 21 | 22 | ''' 23 | ''' Contains related PATH and PATHEXT registry tools. 24 | ''' 25 | Public NotInheritable Class PathUtil 26 | 27 | #Region " Properties " 28 | 29 | ''' 30 | ''' Gets the registry path of the Environment subkey for the current user. 31 | ''' 32 | ''' The registry path of the Environment subkey for the current user. 33 | Public Shared ReadOnly Property EnvironmentPathCurrentUser As String 34 | Get 35 | Return "HKEY_CURRENT_USER\Environment" 36 | End Get 37 | End Property 38 | 39 | ''' 40 | ''' Gets the registry path of the Environment subkey for local machine. 41 | ''' 42 | ''' The registry path of the Environment subkey for local machine. 43 | Public Shared ReadOnly Property EnvironmentPathAllUsers As String 44 | Get 45 | Return "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" 46 | End Get 47 | End Property 48 | 49 | ''' 50 | ''' Gets the default data of the PATH registry value of a 32-Bit Windows. 51 | ''' 52 | ''' The default data of the PATH registry value of a 32-Bit Windows. 53 | Public Shared ReadOnly Property DefaultPathDataWin32 As String 54 | Get 55 | Return "C:\Windows;C:\Windows\System32;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0" 56 | End Get 57 | End Property 58 | 59 | ''' 60 | ''' Gets the default data of the PATH registry value of a 64-Bit Windows. 61 | ''' 62 | ''' The default data of the PATH registry value of a 64-Bit Windows. 63 | Public Shared ReadOnly Property DefaultPathDataWin64 As String 64 | Get 65 | Return "C:\Windows;C:\Windows\System32;C:\Windows\System32\Wbem;C:\Windows\SysWOW64;C:\Windows\System32\WindowsPowerShell\v1.0" 66 | End Get 67 | End Property 68 | 69 | ''' 70 | ''' Gets the default data of the PATHEXt registry value. 71 | ''' 72 | ''' The default data of the PATHEXt registry value. 73 | Public Shared ReadOnly Property DefaultPathExtData As String 74 | Get 75 | Return ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE" 76 | End Get 77 | End Property 78 | 79 | ''' 80 | ''' Gets the registry export string format. 81 | ''' 82 | ''' The registry export string format. 83 | Private Shared ReadOnly Property ExportStringFormat As String 84 | Get 85 | Return "Windows Registry Editor Version 5.00{0}{0}" & 86 | "[HKEY_CURRENT_USER\Environment]{0}" & 87 | """PATH""=""{1}""{0}" & 88 | """PATHEXT""=""{2}""{0}{0}" & 89 | "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]{0}" & 90 | """PATH""=""{3}""{0}" & 91 | """PATHEXT""=""{4}""" 92 | End Get 93 | End Property 94 | 95 | #End Region 96 | 97 | #Region " Enumerations " 98 | 99 | ''' 100 | ''' Specifies the registry user mode. 101 | ''' 102 | Public Enum UserMode 103 | 104 | ''' 105 | ''' The current user (HKCU). 106 | ''' 107 | Current = 0 108 | 109 | ''' 110 | ''' local machine (HKLM). 111 | ''' 112 | AllUsers = 1 113 | 114 | End Enum 115 | 116 | #End Region 117 | 118 | #Region " Constructors " 119 | 120 | ''' 121 | ''' Prevents a default instance of the class from being created. 122 | ''' 123 | Private Sub New() 124 | End Sub 125 | 126 | #End Region 127 | 128 | #Region " Public Methods " 129 | 130 | ''' 131 | ''' Gets the default data of the PATH value for the registry of the specified user (as String). 132 | ''' 133 | ''' The default data of the PATH value for the registry of the specified user. 134 | Public Shared Function GetDefaultPathDataString() As String 135 | 136 | If Not Environment.Is64BitOperatingSystem Then 137 | Return DefaultPathDataWin32 138 | Else 139 | Return DefaultPathDataWin64 140 | End If 141 | 142 | End Function 143 | 144 | ''' 145 | ''' Gets the default data of the PATH value for the registry of the specified user (as Enumerable). 146 | ''' 147 | ''' The default data of the PATH value for the registry of the specified user. 148 | Public Shared Function GetDefaultPathDataList() As IEnumerable(Of String) 149 | 150 | If Not Environment.Is64BitOperatingSystem Then 151 | Return DefaultPathDataWin32.Split({";"c}, StringSplitOptions.RemoveEmptyEntries) 152 | Else 153 | Return DefaultPathDataWin64.Split({";"c}, StringSplitOptions.RemoveEmptyEntries) 154 | End If 155 | 156 | End Function 157 | 158 | ''' 159 | ''' Gets the data of the PATH value on the registry of the specified user (as String). 160 | ''' 161 | ''' The user mode. 162 | ''' The data of the PATH value on the registry of the specified user. 163 | ''' Unexpected enumeration value.;userMode 164 | Public Shared Function GetPathDataString(ByVal userMode As UserMode) As String 165 | 166 | Select Case userMode 167 | 168 | Case PathUtil.UserMode.Current 169 | Return RegEdit.GetValueData(Of String)(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATH") 170 | 171 | Case PathUtil.UserMode.AllUsers 172 | Return RegEdit.GetValueData(Of String)(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATH") 173 | 174 | Case Else 175 | Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode") 176 | 177 | End Select 178 | 179 | End Function 180 | 181 | ''' 182 | ''' Gets the data of the PATH value on the registry of the specified user (as Enumerable). 183 | ''' 184 | ''' The user mode. 185 | ''' The data of the PATH value on the registry of the specified user. 186 | Public Shared Function GetPathDataList(ByVal userMode As UserMode) As IEnumerable(Of String) 187 | 188 | Dim path As String = GetPathDataString(userMode) 189 | 190 | If Not String.IsNullOrEmpty(path) Then 191 | Return path.Split({";"c}, StringSplitOptions.RemoveEmptyEntries) 192 | 193 | Else 194 | Return Enumerable.Empty(Of String) 195 | 196 | End If 197 | 198 | End Function 199 | 200 | ''' 201 | ''' Gets the data of the PATHEXT value on the registry of the specified user (as String). 202 | ''' 203 | ''' The user mode. 204 | ''' The data of the PATHEXT value on the registry of the specified user. 205 | ''' Unexpected enumeration value.;userMode 206 | Public Shared Function GetPathExtDataString(ByVal userMode As UserMode) As String 207 | 208 | Select Case userMode 209 | 210 | Case PathUtil.UserMode.Current 211 | Return RegEdit.GetValueData(Of String)(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATHEXT") 212 | 213 | Case PathUtil.UserMode.AllUsers 214 | Return RegEdit.GetValueData(Of String)(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATHEXT") 215 | 216 | Case Else 217 | Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode") 218 | 219 | End Select 220 | 221 | End Function 222 | 223 | ''' 224 | ''' Gets data of the data of the PATHEXT value on the registry of the specified user (as Enumerable). 225 | ''' 226 | ''' The user mode. 227 | ''' The data of the PATHEXT value on the registry of the specified user. 228 | Public Shared Function GetPathExtDataList(ByVal userMode As UserMode) As IEnumerable(Of String) 229 | 230 | Dim pathExt As String = GetPathExtDataString(userMode) 231 | 232 | If Not String.IsNullOrEmpty(pathExt) Then 233 | Return pathExt.Split({";"c}, StringSplitOptions.RemoveEmptyEntries) 234 | 235 | Else 236 | Return Enumerable.Empty(Of String) 237 | 238 | End If 239 | 240 | End Function 241 | 242 | ''' 243 | ''' Determines whether the PATH value exists on the registry of the specified user. 244 | ''' 245 | ''' The user mode. 246 | ''' true if PATH value exists, false otherwise. 247 | ''' Unexpected enumeration value.;userMode 248 | Public Shared Function PathExists(ByVal userMode As UserMode) As Boolean 249 | 250 | Select Case userMode 251 | 252 | Case PathUtil.UserMode.Current 253 | Return RegEdit.ExistValue(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATH") 254 | 255 | Case PathUtil.UserMode.AllUsers 256 | Return RegEdit.ExistValue(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATH") 257 | 258 | Case Else 259 | Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode") 260 | 261 | End Select 262 | 263 | End Function 264 | 265 | ''' 266 | ''' Determines whether the PATHEXT value exists on the registry of the specified user. 267 | ''' 268 | ''' The user mode. 269 | ''' true if PATHEXT value exists, false otherwise. 270 | ''' Unexpected enumeration value.;userMode 271 | Public Shared Function PathExtExists(ByVal userMode As UserMode) As Boolean 272 | 273 | Select Case userMode 274 | 275 | Case PathUtil.UserMode.Current 276 | Return RegEdit.ExistValue(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATHEXT") 277 | 278 | Case PathUtil.UserMode.AllUsers 279 | Return RegEdit.ExistValue(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATHEXT") 280 | 281 | Case Else 282 | Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode") 283 | 284 | End Select 285 | 286 | End Function 287 | 288 | ''' 289 | ''' Exports the PATH and PATHEXT values to a target registry file. 290 | ''' 291 | ''' The filepath. 292 | ''' 293 | Public Shared Sub Export(ByVal filepath As String) 294 | 295 | Try 296 | IO.File.WriteAllText(filepath, 297 | String.Format(ExportStringFormat, 298 | Environment.NewLine, 299 | GetPathDataString(UserMode.Current), 300 | GetPathExtDataString(UserMode.Current), 301 | GetPathDataString(UserMode.AllUsers), 302 | GetPathExtDataString(UserMode.AllUsers)), 303 | encoding:=System.Text.Encoding.Unicode) 304 | 305 | Catch ex As Exception 306 | Throw 307 | 308 | End Try 309 | 310 | End Sub 311 | 312 | ''' 313 | ''' Creates a PATH value on the registry of the specified user and optionally fills the value with the specified data. 314 | ''' 315 | ''' The user mode. 316 | ''' Unexpected enumeration value.;userMode 317 | Public Shared Sub CreatePath(ByVal userMode As UserMode, 318 | Optional data As String = "") 319 | 320 | Try 321 | Select Case userMode 322 | 323 | Case PathUtil.UserMode.Current 324 | RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATH", valueData:=data) 325 | 326 | Case PathUtil.UserMode.AllUsers 327 | RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATH", valueData:=data) 328 | 329 | Case Else 330 | Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode") 331 | 332 | End Select 333 | 334 | Catch ex As Exception 335 | Throw 336 | 337 | End Try 338 | 339 | End Sub 340 | 341 | ''' 342 | ''' Creates a PATHEXT value on the registry of the specified user and optionally fills the value with the specified data.. 343 | ''' 344 | ''' The user mode. 345 | ''' Unexpected enumeration value.;userMode 346 | Public Shared Sub CreatePathExt(ByVal userMode As UserMode, 347 | Optional data As String = "") 348 | 349 | Try 350 | Select Case userMode 351 | 352 | Case PathUtil.UserMode.Current 353 | RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATHEXT", valueData:=data) 354 | 355 | Case PathUtil.UserMode.AllUsers 356 | RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATHEXT", valueData:=data) 357 | 358 | Case Else 359 | Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode") 360 | 361 | End Select 362 | 363 | Catch ex As Exception 364 | Throw 365 | 366 | End Try 367 | 368 | End Sub 369 | 370 | ''' 371 | ''' Adds a directory into the PATH registry value of the specified user. 372 | ''' 373 | ''' The user mode. 374 | ''' The directory path. 375 | ''' Directory contains invalid character(s).;directory 376 | ''' Unexpected enumeration value.;userMode 377 | Public Shared Sub AddDirectory(ByVal userMode As UserMode, 378 | ByVal directory As String) 379 | 380 | If directory.Any(Function(c As Char) IO.Path.GetInvalidPathChars.Contains(c)) Then 381 | Throw New ArgumentException(message:="Directory contains invalid character(s).", paramName:="directory") 382 | 383 | Else 384 | 385 | Select Case userMode 386 | 387 | Case PathUtil.UserMode.Current 388 | RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATH", 389 | valueData:=String.Join(";"c, GetPathDataList(userMode).Concat({directory}).Distinct).Trim(";"c)) 390 | 391 | Case PathUtil.UserMode.AllUsers 392 | RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATH", 393 | valueData:=String.Join(";"c, GetPathDataList(userMode).Concat({directory}).Distinct).Trim(";"c)) 394 | 395 | Case Else 396 | Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode") 397 | 398 | End Select 399 | 400 | End If 401 | 402 | End Sub 403 | 404 | ''' 405 | ''' Adds a file extension into the PATHEXT registry value of the specified user. 406 | ''' 407 | ''' The user mode. 408 | ''' The file extension. 409 | ''' Unexpected enumeration value.;userMode 410 | Public Shared Sub AddExtension(ByVal userMode As UserMode, 411 | ByVal extension As String) 412 | 413 | If Not extension.StartsWith("."c) Then ' Fix extension. 414 | extension.Insert(0, "."c) 415 | End If 416 | 417 | Select Case userMode 418 | 419 | Case PathUtil.UserMode.Current 420 | RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATHEXT", 421 | valueData:=String.Join(";"c, GetPathExtDataList(userMode).Concat({extension})).Trim(";"c)) 422 | 423 | Case PathUtil.UserMode.AllUsers 424 | RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATHEXT", 425 | valueData:=String.Join(";"c, GetPathExtDataList(userMode).Concat({extension})).Trim(";"c)) 426 | 427 | Case Else 428 | Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode") 429 | 430 | End Select 431 | 432 | End Sub 433 | 434 | ''' 435 | ''' Deletes a directory from the PATH registry value of the specified user. 436 | ''' 437 | ''' The user mode. 438 | ''' The directory path. 439 | Public Shared Sub DeleteDirectory(ByVal userMode As UserMode, 440 | ByVal directory As String) 441 | 442 | Dim dirs As IEnumerable(Of String) = 443 | From dir As String In GetPathDataList(userMode) 444 | Where Not dir.ToLower.Equals(directory, StringComparison.OrdinalIgnoreCase) 445 | 446 | CreatePath(userMode, data:=String.Join(";"c, dirs)) 447 | 448 | End Sub 449 | 450 | ''' 451 | ''' Deletes a directory from the PATH registry value of the specified user. 452 | ''' 453 | ''' The user mode. 454 | ''' The directory index, 0 = First. 455 | ''' Directory index is out of range. 456 | Public Shared Sub DeleteDirectory(ByVal userMode As UserMode, 457 | ByVal index As Integer) 458 | 459 | Dim dirs As List(Of String) = GetPathDataList(userMode).ToList 460 | 461 | If (dirs.Count > index) Then 462 | dirs.RemoveAt(index) 463 | Else 464 | Throw New IndexOutOfRangeException(Message:="Directory index is out of range.") 465 | End If 466 | 467 | CreatePath(userMode, data:=String.Join(";"c, dirs)) 468 | 469 | End Sub 470 | 471 | ''' 472 | ''' Deletes a file extension from the PATHEXT registry value of the specified user. 473 | ''' 474 | ''' The user mode. 475 | ''' The file extension. 476 | Public Shared Sub DeleteExtension(ByVal userMode As UserMode, 477 | ByVal extension As String) 478 | 479 | If Not extension.StartsWith("."c) Then ' Fix extension. 480 | extension.Insert(0, "."c) 481 | End If 482 | 483 | Dim exts As IEnumerable(Of String) = 484 | From ext As String In GetPathExtDataList(userMode) 485 | Where Not ext.ToLower.Equals(extension, StringComparison.OrdinalIgnoreCase) 486 | 487 | CreatePath(userMode, data:=String.Join(";"c, exts)) 488 | 489 | End Sub 490 | 491 | ''' 492 | ''' Deletes a file extension from the PATHEXT registry value of the specified user. 493 | ''' 494 | ''' The user mode. 495 | ''' The file extension index, 0 = First. 496 | ''' File extension index is out of range. 497 | Public Shared Sub DeleteExtension(ByVal userMode As UserMode, 498 | ByVal index As Integer) 499 | 500 | Dim exts As List(Of String) = GetPathExtDataList(userMode).ToList 501 | 502 | If (exts.Count > index) Then 503 | exts.RemoveAt(index) 504 | Else 505 | Throw New IndexOutOfRangeException(Message:="File extension index is out of range.") 506 | End If 507 | 508 | CreatePathExt(userMode, data:=String.Join(";"c, exts)) 509 | 510 | End Sub 511 | 512 | ''' 513 | ''' Determines whether the PATH registry value of the specified user contains a directory. 514 | ''' 515 | ''' The usermode. 516 | ''' The directory path. 517 | ''' true if contains the specified directory; false otherwise. 518 | Public Shared Function ContainsDirectory(ByVal usermode As UserMode, 519 | ByVal directory As String) As Boolean 520 | 521 | Dim dirs As IEnumerable(Of String) = GetPathDataList(usermode) 522 | 523 | If dirs IsNot Nothing Then 524 | Return dirs.Any(Function(dir As String) dir.Equals(directory, StringComparison.OrdinalIgnoreCase)) 525 | Else 526 | Return False 527 | End If 528 | 529 | End Function 530 | 531 | ''' 532 | ''' Determines whether the PATHEXT registry value of the specified user contains a directory. 533 | ''' 534 | ''' The usermode. 535 | ''' The file extension. 536 | ''' true if contains the specified file extension; false otherwise. 537 | Public Shared Function ContainsExtension(ByVal usermode As UserMode, 538 | ByVal extension As String) As Boolean 539 | 540 | If Not extension.StartsWith("."c) Then ' Fix extension. 541 | extension.Insert(0, "."c) 542 | End If 543 | 544 | Dim exts As IEnumerable(Of String) = GetPathExtDataList(usermode) 545 | 546 | If exts IsNot Nothing Then 547 | Return exts.Any(Function(ext As String) ext.Equals(extension, StringComparison.OrdinalIgnoreCase)) 548 | Else 549 | Return False 550 | End If 551 | 552 | End Function 553 | 554 | #End Region 555 | 556 | End Class 557 | 558 | End Namespace 559 | 560 | #End Region -------------------------------------------------------------------------------- /Solution/PATHS/UserInterface/HelpSection.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Author : Elektro 3 | ' Assembly : HelpSection 4 | ' Modified : 09-April-2015 5 | ' Usage : Use *F##* as the ForeColor beginning delimiter, use *-F* to restore the console forecolor. 6 | ' Use *B##* as the BackColor beginning delimiter, use *-B* to restore the console BackColor. 7 | ' *********************************************************************** 8 | ' 9 | ' Copyright (c) Elektro Studios. All rights reserved. 10 | ' 11 | ' *********************************************************************** 12 | 13 | #Region " Usage Examples " 14 | 15 | #Region " Example Without Colorization " 16 | 17 | 'Module Module1 18 | 19 | ' Sub Main() 20 | 21 | ' Console.Title = HelpSection.Help..Value 22 | 23 | ' Dim sb As New System.Text.StringBuilder 24 | ' sb.AppendLine(HelpSection.Help.<Logo>.Value) 25 | ' sb.AppendLine(HelpSection.Help.<Separator>.Value) 26 | ' sb.AppendLine(String.Format(" Executable name.......: {0}", HelpSection.Help.<Process>.Value)) 27 | ' sb.AppendLine(String.Format(" Application name......: {0}", HelpSection.Help.<Name>.Value)) 28 | ' sb.AppendLine(String.Format(" Application version...: {0}", HelpSection.Help.<Version>.Value)) 29 | ' sb.AppendLine(String.Format(" Application author....: {0}", HelpSection.Help.<Author>.Value)) 30 | ' sb.AppendLine(String.Format(" Application copyright.: {0}", HelpSection.Help.<Copyright>.Value)) 31 | ' sb.AppendLine(String.Format(" Author website........: {0}", HelpSection.Help.<Website>.Value)) 32 | ' sb.AppendLine(String.Format(" Author Skype..........: {0}", HelpSection.Help.<Skype>.Value)) 33 | ' sb.AppendLine(String.Format(" Author Email..........: {0}", HelpSection.Help.<Email>.Value)) 34 | ' sb.AppendLine(HelpSection.Help.<Separator>.Value) 35 | ' sb.AppendLine(HelpSection.Help.<Syntax>.Value) 36 | ' sb.AppendLine(HelpSection.Help.<SyntaxExtra>.Value) 37 | ' sb.AppendLine(HelpSection.Help.<UsageExamples>.Value) 38 | 39 | ' HelpSection.WriteLine(sb.ToString) 40 | 41 | ' Threading.Thread.Sleep(60000) 42 | 43 | ' End Sub 44 | 45 | 'End Module 46 | 47 | #End Region 48 | 49 | #Region " Example With Colorization " 50 | 51 | 'Module Module1 52 | 53 | ' Sub Main() 54 | 55 | ' Console.Title = HelpSection.ColorizedHelp.<Title>.Value 56 | 57 | ' Dim sb As New System.Text.StringBuilder 58 | ' sb.AppendLine(HelpSection.ColorizedHelp.<Logo>.Value) 59 | ' sb.AppendLine(HelpSection.ColorizedHelp.<Separator>.Value) 60 | ' sb.AppendLine(String.Format(" Executable name.......: {0}", HelpSection.ColorizedHelp.<Process>.Value)) 61 | ' sb.AppendLine(String.Format(" Application name......: {0}", HelpSection.ColorizedHelp.<Name>.Value)) 62 | ' sb.AppendLine(String.Format(" Application version...: {0}", HelpSection.ColorizedHelp.<Version>.Value)) 63 | ' sb.AppendLine(String.Format(" Application author....: {0}", HelpSection.ColorizedHelp.<Author>.Value)) 64 | ' sb.AppendLine(String.Format(" Application copyright.: {0}", HelpSection.ColorizedHelp.<Copyright>.Value)) 65 | ' sb.AppendLine(String.Format(" Author website........: {0}", HelpSection.ColorizedHelp.<Website>.Value)) 66 | ' sb.AppendLine(String.Format(" Author Skype..........: {0}", HelpSection.ColorizedHelp.<Skype>.Value)) 67 | ' sb.AppendLine(String.Format(" Author Email..........: {0}", HelpSection.ColorizedHelp.<Email>.Value)) 68 | ' sb.AppendLine(HelpSection.ColorizedHelp.<Separator>.Value) 69 | ' sb.AppendLine(HelpSection.ColorizedHelp.<Syntax>.Value) 70 | ' sb.AppendLine(HelpSection.ColorizedHelp.<SyntaxExtra>.Value) 71 | ' sb.AppendLine(HelpSection.ColorizedHelp.<UsageExamples>.Value) 72 | 73 | ' WriteColoredTextLine(sb.ToString, {"*"c}) 74 | 75 | ' Threading.Thread.Sleep(60000) 76 | 77 | ' End Sub 78 | 79 | 'End Module 80 | 81 | #End Region 82 | 83 | #End Region 84 | 85 | #Region " ConsoleColor Enumeration Helper " 86 | 87 | ' Black = 0 88 | ' DarkBlue = 1 89 | ' DarkGreen = 2 90 | ' DarkCyan = 3 91 | ' DarkRed = 4 92 | ' DarkMagenta = 5 93 | ' DarkYellow = 6 94 | ' Gray = 7 95 | ' DarkGray = 8 96 | ' Blue = 9 97 | ' Green = 10 98 | ' Cyan = 11 99 | ' Red = 12 100 | ' Magenta = 13 101 | ' Yellow = 14 102 | ' White = 15 103 | 104 | #End Region 105 | 106 | #Region " Option Statements " 107 | 108 | Option Explicit On 109 | Option Strict On 110 | Option Infer Off 111 | 112 | #End Region 113 | 114 | #Region " HelpSection " 115 | 116 | Namespace UserInterface 117 | 118 | ''' <summary> 119 | ''' Class that manages the Help documentation of a Console application with colorization capabilities. 120 | ''' </summary> 121 | Public NotInheritable Class HelpSection 122 | 123 | #Region " Members " 124 | 125 | ''' <summary> 126 | ''' Gets the name of the current process. 127 | ''' </summary> 128 | Private Shared ReadOnly processName As String = 129 | Process.GetCurrentProcess.MainModule.ModuleName 130 | 131 | ''' <summary> 132 | ''' Use this var into an XML if need to escape a 'GreaterThan' character. 133 | ''' </summary> 134 | Private ReadOnly greaterThanChar As Char = ">"c 135 | 136 | ''' <summary> 137 | ''' Use this var into an XML if need to escape a 'LowerThan' character. 138 | ''' </summary> 139 | Private ReadOnly lowerThanChar As Char = "<"c 140 | 141 | #End Region 142 | 143 | #Region " Help Text " 144 | 145 | ''' <summary> 146 | ''' Contains Help information such as Author, Syntax and Example usages. 147 | ''' These strings are color-delimited to print a colorized output console, 148 | ''' using the 'WriteColoredText' methods written by Elektro. 149 | ''' </summary> 150 | Friend Shared ReadOnly ColorizedHelp As XElement = 151 | <Help> 152 | 153 | <!-- Application title --> 154 | <Title>PATHS .:: By ElektroStudios ::. 155 | 156 | 157 | *F07*PATHS*-F* 158 | 159 | 160 | *F07*ElektroStudios*-F* 161 | 162 | 163 | *F07*1.4*-F* 164 | 165 | 166 | *F07*Copyright © ElektroStudios 2015-2024*-F* 167 | 168 | 169 | *F07*https://github.com/ElektroStudios/PATHS-a-command-line-app-to-manage-PATH-environment*-F* 170 | 171 | 172 | *F11* 173 | ::::::::: ::: ::::::::::: ::: ::: :::::::: 174 | :+: :+: :+: :+: :+: :+: :+: :+: :+: 175 | +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ 176 | +#++:++#+ +#++:++#++: +#+ +#++:++#++ +#++:++#++ 177 | +#+ +#+ +#+ +#+ +#+ +#+ +#+ 178 | #+# #+# #+# #+# #+# #+# #+# #+# 179 | ### ### ### ### ### ### ######## *F07*v1.4 180 | *-F* 181 | 182 | 183 | 184 | *F11*------------------------------------------------------*F14*>>>>*-F* 185 | 186 | 187 | 188 | *F11*[+]*-F* *F14*Syntax*-F* 189 | 190 | *F07*<%= processName %> *F10*/OPTIONS*-F* *F10*[*F07*DIRECTORY PATH or FILE EXTENSION or ENTRY INDEX*F10*]*-F* 191 | 192 | 193 | 194 | *F11*[+]*-F* *F14*Switches*-F* 195 | 196 | *F10*/L *F08*(or)*F10* /List *F08*| *F07*Lists the PATH entries.*-F* 197 | *F10*/E *F08*(or)*F10* /Export *F08*| *F07*Exports PATH and PATHEXT entries to a registry script file.*-F* 198 | *F10*/C *F08*(or)*F10* /Clean *F08*| *F07*Clean duplicates and missing directory paths in PATH and PATHEXT.*-F* 199 | *F10*/R *F08*(or)*F10* /Restore *F08*| *F07*Restores the PATH entries to Windows defaults.*-F* 200 | *F10* *F08* *F10* *F08*| 201 | *F10*/Add -User *F08**F08**F08*| *F07*Adda a directory to current user's PATH.*-F* 202 | *F10*/Add -Machine *F08**F08**F08*| *F07*Adds a directory to local machine PATH.*-F* 203 | *F10*/A *F08*(or)*F10* /Add *F08*| *F07*Adds a directory to current user's and local machine PATHs.*-F* 204 | *F10* *F08* *F10* *F08*| 205 | *F10*/Del -User *F08**F08**F08*| *F07*Deletes a directory from current user's PATH.*-F* 206 | *F10*/Del -Machine *F08**F08**F08*| *F07*Deletes a directory from local machine PATH.*-F* 207 | *F10*/D *F08*(or)*F10* /Del *F08*| *F07*Deletes a directory from current user's and local machine PATHs.*-F* 208 | *F10* *F08* *F10* *F08*| 209 | *F10*/AddExt -User *F08**F08**F08*| *F07*Adds a file extension to current user's PATHEXT.*-F* 210 | *F10*/AddExt -Machine *F08**F08**F08*| *F07*Adds a file extension to local machine PATHEXT.*-F* 211 | *F10*/AddExt*F08**F08* *F08*| *F07*Adds a file extension to current user's and local machine PATHEXTs.*-F* 212 | *F10* *F08* *F10* *F08*| 213 | *F10*/DelExt -User *F08**F08**F08*| *F07*Deletes a file extension from current user's PATHEXT.*-F* 214 | *F10*/DelExt -Machine *F08**F08**F08*| *F07*Deletes a file extension from local machine PATHEXT.*-F* 215 | *F10*/DelExt *F08**F08**F08*| *F07*Deletes a file extension from current user's and local machine PATHEXTs.*-F* 216 | *F10* *F08* *F10* *F08*| 217 | *F10*/? *F08*(or)*F10* /Help *F08*| *F07*Shows this help.*-F* 218 | 219 | *F11*[+]*-F* *F14*Switch value types*-F* 220 | 221 | *F10*Note: You can list all the entry indices using command:*-F* *F10*<%= processName %> /List*-F* 222 | 223 | *F10*/Del -User*-F* (*F07*Directory Path*-F* or *F07*Entry Index*-F*) 224 | *F10*/Del -Machine*-F* (*F07*Directory Path*-F* or *F07*Entry Index*-F*) 225 | 226 | *F10*/AddExt -User*-F* (*F07*File Extension*-F*) 227 | *F10*/AddExt -Machine*-F* (*F07*File Extension*-F*) 228 | 229 | *F10*/DelExt -User*-F* (*F07*File Extension*-F*) 230 | *F10*/DelExt -Machine*-F* (*F07*File Extension*-F*) 231 | 232 | 233 | 234 | *F11*[+]*-F* *F14*Usage examples*-F* 235 | 236 | *F10*<%= processName %> /List*-F* 237 | *F08*(Lists the entries of PATH and PATHEXT)*-F* 238 | 239 | *F10*<%= processName %> /Clean*-F* 240 | *F08*(Clean duplicates and missing directory paths in PATH and PATHEXT)*-F* 241 | 242 | *F10*<%= processName %> /Restore*-F* 243 | *F08*(Restores the PATH and PATHEXT to Windows defaults)*-F* 244 | 245 | *F10*<%= processName %> /Export "C:\Registry File.reg"*-F* 246 | *F08*(Exports the PATH and PATHEXT entries to the specified registry script file)*-F* 247 | 248 | *F10*<%= processName %> /Add -User "C:\Directory"*-F* 249 | *F08*(Adds a directory with name "C:\Directory" to current user's PATH)*-F* 250 | 251 | *F10*<%= processName %> /Add -Machine "C:\Directory"*-F* 252 | *F08*(Adds a directory with name "C:\Directory" to local machine PATH)*-F* 253 | 254 | *F10*<%= processName %> /Add "C:\Directory"*-F* 255 | *F08*(Adds a directory with name "C:\Directory" to current user's and local machine PATHs)*-F* 256 | 257 | *F10*<%= processName %> /Del -User "C:\Directory"*-F* 258 | *F08*(Deletes any directory with name "C:\Directory" from current user's PATH)*-F* 259 | 260 | *F10*<%= processName %> /Del -Machine "C:\Directory"*-F* 261 | *F08*(Deletes any directory with name "C:\Directory" from local machine PATH)*-F* 262 | 263 | *F10*<%= processName %> /Del "C:\Directory"*-F* 264 | *F08*(Deletes any directory with name "C:\Directory" from current user's and local machine PATHs)*-F* 265 | 266 | *F10*<%= processName %> /Del -User 5*-F* 267 | *F08*(Deletes the entry with index 5 from current user's PATH)*-F* 268 | 269 | *F10*<%= processName %> /Del -Machine 5*-F* 270 | *F08*(Deletes the entry with index 5 from local machine PATH)*-F* 271 | 272 | *F10*<%= processName %> /AddExt -User ".test"*-F* 273 | *F08*(Adds a file extension with name ".test" to current user's PATHEXT)*-F* 274 | 275 | *F10*<%= processName %> /AddExt -Machine ".test"*-F* 276 | *F08*(Adds a file extension with name ".test" to local machine PATHEXT)*-F* 277 | 278 | *F10*<%= processName %> /AddExt ".test"*-F* 279 | *F08*(Adds a file extension with name ".test" to current user's and local machine PATHEXTs)*-F* 280 | 281 | *F10*<%= processName %> /DelExt -User ".test"*-F* 282 | *F08*(Deletes any file extension with name ".test" from current user's PATHEXT)*-F* 283 | 284 | *F10*<%= processName %> /DelExt -Machine ".test"*-F* 285 | *F08*(Deletes any file extension with name ".test" from local machine PATHEXT)*-F* 286 | 287 | *F10*<%= processName %> /DelExt ".test"*-F* 288 | *F08*(Deletes any file extension with name ".test" from current user's and local machine PATHEXTs)*-F* 289 | 290 | 291 | 292 | #End Region 293 | 294 | End Class 295 | 296 | End Namespace 297 | 298 | #End Region -------------------------------------------------------------------------------- /Solution/PATHS/UserInterface/Main.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Author : Elektro 3 | ' Assembly : PATHS 4 | ' Modified : 09-April-2015 5 | ' *********************************************************************** 6 | ' 7 | ' Copyright (c) Elektro Studios. All rights reserved. 8 | ' 9 | ' *********************************************************************** 10 | 11 | #Region " Option Statements " 12 | 13 | Option Explicit On 14 | Option Strict On 15 | Option Infer Off 16 | 17 | #End Region 18 | 19 | #Region " Imports " 20 | 21 | Imports PATHS.Tools 22 | 23 | #End Region 24 | 25 | #Region " Main " 26 | 27 | Namespace UserInterface 28 | 29 | ''' 30 | ''' The Main module. 31 | ''' 32 | Module Main 33 | 34 | #Region " Data Members " 35 | 36 | ' Color for invalid PATH entries 37 | Private errorColor As ConsoleColor = ConsoleColor.Red 38 | 39 | #End Region 40 | 41 | #Region " Entry Point " 42 | 43 | ''' 44 | ''' Defines the entry point of the application. 45 | ''' 46 | Public Sub Main() 47 | 48 | ConsoleUtil.WriteColoredTextLine(HelpSection.ColorizedHelp..Value, {"*"c}) 49 | ConsoleUtil.WriteColoredTextLine(HelpSection.ColorizedHelp..Value, {"*"c}) 50 | ParseArguments() 51 | 52 | End Sub 53 | 54 | #End Region 55 | 56 | #Region " Arguments " 57 | 58 | ''' 59 | ''' Parses the arguments of the application. 60 | ''' 61 | Private Sub ParseArguments() 62 | 63 | If My.Application.CommandLineArgs.Count = 0 Then 64 | ShowHelp() 65 | Environment.Exit(0) 66 | End If 67 | 68 | Dim pathIndex As Integer = 0 69 | 70 | ' Parsing of parametters without aditional values required 71 | Select Case My.Application.CommandLineArgs(0).ToLower 72 | 73 | Case "/l", "/list" ' List 74 | ListPath() 75 | ListPathext() 76 | Environment.Exit(0) 77 | 78 | Case "/c", "/clean" ' Clean 79 | Clean() 80 | Environment.Exit(0) 81 | 82 | Case "/r", "/restore" ' Restore 83 | RestoreDefaults() 84 | Environment.Exit(0) 85 | 86 | Case "/?", "/help" ' Help 87 | ShowHelp() 88 | Environment.Exit(0) 89 | 90 | End Select 91 | 92 | ' Parsing of parametters with aditional values required 93 | For x As Integer = 0 To My.Application.CommandLineArgs.Count - 1 94 | 95 | Select Case My.Application.CommandLineArgs(x).ToLower 96 | 97 | Case "/a", "/add" ' Add 98 | 99 | ' Additional argument prevention check 100 | If Not My.Application.CommandLineArgs.Count > (x + 1) _ 101 | OrElse My.Application.CommandLineArgs(x + 1) = String.Empty Then 102 | 103 | DisplayError(1) 104 | 105 | End If 106 | 107 | Select Case My.Application.CommandLineArgs(x + 1).ToLower 108 | 109 | Case "-user" ' Add to current user's Path 110 | 111 | ' Additional argument prevention check 112 | If Not My.Application.CommandLineArgs.Count = x + 3 _ 113 | OrElse My.Application.CommandLineArgs(x + 2) = String.Empty Then 114 | 115 | DisplayError(2) 116 | 117 | End If 118 | 119 | AddDirectoryCurrentUser(My.Application.CommandLineArgs(x + 2).Trim) 120 | 121 | Case "-machine" ' Add to Local Machine Path 122 | 123 | ' Additional argument prevention check 124 | If Not My.Application.CommandLineArgs.Count = x + 3 _ 125 | OrElse My.Application.CommandLineArgs(x + 2) = String.Empty Then 126 | 127 | DisplayError(3) 128 | 129 | End If 130 | 131 | AddDirectoryAllUsers(My.Application.CommandLineArgs(x + 2).Trim) 132 | 133 | Case Else ' Add to both 134 | 135 | AddDirectoryCurrentUser(My.Application.CommandLineArgs(x + 1)) 136 | AddDirectoryAllUsers(My.Application.CommandLineArgs(x + 1)) 137 | 138 | End Select 139 | 140 | Environment.Exit(0) 141 | 142 | Case "/d", "/del" ' Delete 143 | 144 | ' Additional argument prevention check 145 | If Not My.Application.CommandLineArgs.Count > (x + 1) _ 146 | OrElse My.Application.CommandLineArgs(x + 1) = String.Empty Then 147 | 148 | DisplayError(4) 149 | 150 | ElseIf Integer.TryParse(My.Application.CommandLineArgs(x + 1), pathIndex) Then 151 | 152 | DisplayError(5) 153 | 154 | End If 155 | 156 | Select Case My.Application.CommandLineArgs(x + 1).ToLower 157 | 158 | Case "-user" ' Delete from current user's Path 159 | 160 | ' Additional argument prevention check 161 | If Not My.Application.CommandLineArgs.Count = x + 3 _ 162 | OrElse My.Application.CommandLineArgs(x + 2) = String.Empty Then 163 | 164 | DisplayError(6) 165 | 166 | End If 167 | 168 | If Integer.TryParse(My.Application.CommandLineArgs(x + 2), pathIndex) Then 169 | DeleteDirectoryCurrentUser(pathIndex) 170 | Else 171 | DeleteDirectoryCurrentUser(My.Application.CommandLineArgs(x + 2).Trim) 172 | End If 173 | 174 | Case "-machine" ' Delete from Local Machine Path 175 | 176 | ' Additional argument prevention check 177 | If Not My.Application.CommandLineArgs.Count = x + 3 _ 178 | OrElse My.Application.CommandLineArgs(x + 2) = String.Empty Then 179 | 180 | DisplayError(7) 181 | 182 | End If 183 | 184 | If Integer.TryParse(My.Application.CommandLineArgs(x + 2), pathIndex) Then 185 | DeleteDirectoryAllUsers(pathIndex) 186 | Else 187 | DeleteDirectoryAllUsers(My.Application.CommandLineArgs(x + 2).Trim) 188 | End If 189 | 190 | Case Else ' Delete from both 191 | 192 | DeleteDirectoryCurrentUser(My.Application.CommandLineArgs(x + 1).Trim) 193 | DeleteDirectoryAllUsers(My.Application.CommandLineArgs(x + 1).Trim) 194 | 195 | End Select 196 | 197 | Environment.Exit(0) 198 | 199 | Case "/e", "/export" ' Export 200 | 201 | ' Additional argument prevention check 202 | If Not My.Application.CommandLineArgs.Count = x + 2 _ 203 | OrElse My.Application.CommandLineArgs(x + 1) = String.Empty Then 204 | 205 | DisplayError(8) 206 | 207 | End If 208 | 209 | Export(My.Application.CommandLineArgs(x + 1)) 210 | Environment.Exit(0) 211 | 212 | Case "/addext" ' Add extension to PATHEXT 213 | 214 | ' Additional argument prevention check 215 | If Not My.Application.CommandLineArgs.Count > (x + 1) _ 216 | OrElse My.Application.CommandLineArgs(x + 1) = String.Empty Then 217 | 218 | DisplayError(9) 219 | 220 | End If 221 | 222 | Select Case My.Application.CommandLineArgs(x + 1).ToLower 223 | 224 | Case "-user" ' Add to current user's PATHEXT 225 | 226 | ' Additional argument prevention check 227 | If Not My.Application.CommandLineArgs.Count = x + 3 _ 228 | OrElse My.Application.CommandLineArgs(x + 2) = String.Empty Then 229 | 230 | DisplayError(2) 231 | 232 | End If 233 | 234 | AddExtensionCurrentUser(My.Application.CommandLineArgs(x + 2).Trim) 235 | 236 | Case "-machine" ' Add to Local Machine PATHEXT 237 | 238 | ' Additional argument prevention check 239 | If Not My.Application.CommandLineArgs.Count = x + 3 _ 240 | OrElse My.Application.CommandLineArgs(x + 2) = String.Empty Then 241 | 242 | DisplayError(3) 243 | 244 | End If 245 | 246 | AddExtensionAllUsers(My.Application.CommandLineArgs(x + 2).Trim) 247 | 248 | Case Else ' Add to both 249 | 250 | AddExtensionCurrentUser(My.Application.CommandLineArgs(x + 1)) 251 | AddExtensionAllUsers(My.Application.CommandLineArgs(x + 1)) 252 | 253 | End Select 254 | 255 | Environment.Exit(0) 256 | 257 | Case "/delext" ' Delete extension from PATHEXT 258 | 259 | ' Additional argument prevention check 260 | If Not My.Application.CommandLineArgs.Count > (x + 1) _ 261 | OrElse My.Application.CommandLineArgs(x + 1) = String.Empty Then 262 | 263 | DisplayError(10) 264 | 265 | End If 266 | 267 | Select Case My.Application.CommandLineArgs(x + 1).ToLower 268 | 269 | Case "-user" ' Delete extension from current user's PATHEXT 270 | 271 | ' Additional argument prevention check 272 | If Not My.Application.CommandLineArgs.Count = x + 3 _ 273 | OrElse My.Application.CommandLineArgs(x + 2) = String.Empty Then 274 | 275 | DisplayError(13) 276 | 277 | End If 278 | 279 | DeleteExtensionCurrentUser(My.Application.CommandLineArgs(x + 2).Trim) 280 | 281 | Case "-machine" ' Delete extension from Local Machine PATHEXT 282 | 283 | ' Additional argument prevention check 284 | If Not My.Application.CommandLineArgs.Count = x + 3 _ 285 | OrElse My.Application.CommandLineArgs(x + 2) = String.Empty Then 286 | 287 | DisplayError(14) 288 | 289 | End If 290 | 291 | DeleteExtensionAllUsers(My.Application.CommandLineArgs(x + 2).Trim) 292 | 293 | Case Else ' Delete extension from both 294 | 295 | DeleteExtensionCurrentUser(My.Application.CommandLineArgs(x + 1)) 296 | DeleteExtensionAllUsers(My.Application.CommandLineArgs(x + 1)) 297 | 298 | End Select 299 | 300 | Environment.Exit(0) 301 | 302 | End Select 303 | 304 | Next x ' Argument 305 | 306 | ShowHelp() ' Launch help 'cause the parametter can't be recognized 307 | Environment.Exit(1) 308 | 309 | End Sub 310 | 311 | #End Region 312 | 313 | #Region " PATH Methods " 314 | 315 | ''' 316 | ''' Adds a directory into the current user's PATH. 317 | ''' 318 | ''' The directory. 319 | Private Sub AddDirectoryCurrentUser(ByVal directory As String) 320 | 321 | If Not PathUtil.PathExists(PathUtil.UserMode.Current) Then 322 | PathUtil.CreatePath(PathUtil.UserMode.Current) 323 | End If 324 | 325 | Select Case PathUtil.ContainsDirectory(PathUtil.UserMode.Current, directory) 326 | 327 | Case True 328 | Console.WriteLine() 329 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F12*[X] ERROR*F08*: *F07*""{0}"" already exists in current user's PATH.*-F*", directory), {"*"c}) 330 | 331 | Case Else 332 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Adding *F07*""{0}"" into current user's PATH...*-F*", directory), {"*"c}) 333 | Try 334 | PathUtil.AddDirectory(PathUtil.UserMode.Current, directory) 335 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*Directory successfully added into current user's PATH*-F*", {"*"c}) 336 | Catch ex As System.ArgumentException 337 | ConsoleUtil.WriteColoredTextLine(" *F12*[X] ERROR*F08*: *F07*Directory contains invalid characters.*-F*", {"*"c}) 338 | End Try 339 | Console.WriteLine() 340 | 341 | End Select 342 | 343 | End Sub 344 | 345 | ''' 346 | ''' Adds a directory into the local machine PATH. 347 | ''' 348 | ''' The directory. 349 | Private Sub AddDirectoryAllUsers(ByVal directory As String) 350 | 351 | If Not PathUtil.PathExists(PathUtil.UserMode.AllUsers) Then 352 | PathUtil.CreatePath(PathUtil.UserMode.AllUsers) 353 | End If 354 | 355 | Select Case PathUtil.ContainsDirectory(PathUtil.UserMode.AllUsers, directory) 356 | 357 | Case True 358 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F12*[X] ERROR*F08*: *F07*""{0}"" already exists in local machine PATH.*-F*", directory), {"*"c}) 359 | 360 | Case Else 361 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Adding *F07*""{0}"" into local machine PATH...*-F*", directory), {"*"c}) 362 | Try 363 | PathUtil.AddDirectory(PathUtil.UserMode.AllUsers, directory) 364 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*Directory successfully added into local machine PATH*-F*", {"*"c}) 365 | Catch ex As System.ArgumentException 366 | ConsoleUtil.WriteColoredTextLine(" *F12*[X] ERROR*F08*: *F07*Directory contains invalid characters.*-F*", {"*"c}) 367 | End Try 368 | Console.WriteLine() 369 | 370 | End Select 371 | 372 | End Sub 373 | 374 | ''' 375 | ''' Deletes a directory from the current user's PATH. 376 | ''' 377 | ''' The directory. 378 | Private Sub DeleteDirectoryCurrentUser(ByVal directory As String) 379 | 380 | If Not PathUtil.PathExists(PathUtil.UserMode.Current) Then 381 | PathUtil.CreatePath(PathUtil.UserMode.Current) 382 | End If 383 | 384 | Select Case PathUtil.ContainsDirectory(PathUtil.UserMode.Current, directory) 385 | 386 | Case False 387 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F12*[X] ERROR*F08*: *F07*""{0}"" doesn't exists in current user's PATH.*-F*", directory), {"*"c}) 388 | 389 | Case Else 390 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Deleting *F07*""{0}"" from current user's PATH...*-F*", directory), {"*"c}) 391 | PathUtil.DeleteDirectory(PathUtil.UserMode.Current, directory) 392 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*Directory successfully deleted from current user's PATH.*-F*", {"*"c}) 393 | Console.WriteLine() 394 | 395 | End Select 396 | 397 | End Sub 398 | 399 | ''' 400 | ''' Deletes a directory from the current user's PATH. 401 | ''' 402 | ''' The directory index, 0 = First. 403 | Private Sub DeleteDirectoryCurrentUser(ByVal index As Integer) 404 | 405 | If Not PathUtil.PathExists(PathUtil.UserMode.Current) Then 406 | PathUtil.CreatePath(PathUtil.UserMode.Current) 407 | End If 408 | 409 | Dim dirs As IEnumerable(Of String) = PathUtil.GetPathDataList(PathUtil.UserMode.Current) 410 | 411 | Select Case dirs.Count < (index + 1) 412 | 413 | Case True 414 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F12*[X] ERROR*F08*: *F07*Directory index *F06*{0} is out of range.*-F*", index), {"*"c}) 415 | 416 | Case Else 417 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Deleting index *F07*""{0}"" from current user's PATH...*-F*", index), {"*"c}) 418 | PathUtil.DeleteDirectory(PathUtil.UserMode.Current, index) 419 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*Directory successfully deleted from current user's PATH.*-F*", {"*"c}) 420 | Console.WriteLine() 421 | 422 | End Select 423 | 424 | End Sub 425 | 426 | ''' 427 | ''' Deletes a directory from the local machine PATH. 428 | ''' 429 | ''' The directory. 430 | Private Sub DeleteDirectoryAllUsers(ByVal directory As String) 431 | 432 | If Not PathUtil.PathExists(PathUtil.UserMode.AllUsers) Then 433 | PathUtil.CreatePath(PathUtil.UserMode.AllUsers) 434 | End If 435 | 436 | Select Case PathUtil.ContainsDirectory(PathUtil.UserMode.AllUsers, directory) 437 | 438 | Case False 439 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F12*[X] ERROR*F08*: *F07*""{0}"" doesn't exists in local machine PATH.*-F*", directory), {"*"c}) 440 | 441 | Case Else 442 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Deleting *F07*""{0}"" from local machine PATH...*-F*", directory), {"*"c}) 443 | PathUtil.DeleteDirectory(PathUtil.UserMode.AllUsers, directory) 444 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*Directory successfully deleted from local machine PATH.*-F*", {"*"c}) 445 | Console.WriteLine() 446 | 447 | End Select 448 | 449 | End Sub 450 | 451 | ''' 452 | ''' Deletes a directory from the local machine PATH. 453 | ''' 454 | ''' The directory index, 0 = First. 455 | Private Sub DeleteDirectoryAllUsers(ByVal index As Integer) 456 | 457 | If Not PathUtil.PathExists(PathUtil.UserMode.AllUsers) Then 458 | PathUtil.CreatePath(PathUtil.UserMode.AllUsers) 459 | End If 460 | 461 | Dim dirs As IEnumerable(Of String) = PathUtil.GetPathDataList(PathUtil.UserMode.AllUsers) 462 | 463 | Select Case dirs.Count < (index + 1) 464 | 465 | Case True 466 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F12*[X] ERROR*F08*: *F07*Directory index *F06*{0} is out of range.*-F*", index), {"*"c}) 467 | 468 | Case Else 469 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Deleting index *F07*""{0}"" from local machine PATH...*-F*", index), {"*"c}) 470 | PathUtil.DeleteDirectory(PathUtil.UserMode.AllUsers, index) 471 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*Directory successfully deleted from local machine PATH.*-F*", {"*"c}) 472 | Console.WriteLine() 473 | 474 | End Select 475 | 476 | End Sub 477 | 478 | ''' 479 | ''' Exports PATH and PATHEXT to the specified file path. 480 | ''' 481 | ''' The file path. 482 | Private Sub Export(ByVal filePath As String) 483 | 484 | If filePath.Any(Function(c As Char) IO.Path.GetInvalidPathChars.Contains(c)) Then 485 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F12*[X] ERROR*F08*: *F07*Cannot proceed because ""*F08*{0}*F07*"" contains invalid characters.*-F*", filePath), {"*"c}) 486 | Environment.Exit(1) 487 | End If 488 | 489 | PathUtil.Export(filePath) 490 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*Export done.*-F*", {"*"c}) 491 | 492 | End Sub 493 | 494 | ''' 495 | ''' Lists the PATH. 496 | ''' 497 | Private Sub ListPath() 498 | 499 | Dim dirsCurrentUser As IEnumerable(Of String) = PathUtil.GetPathDataList(PathUtil.UserMode.Current) 500 | Dim dirsAllUsers As IEnumerable(Of String) = PathUtil.GetPathDataList(PathUtil.UserMode.AllUsers) 501 | Dim dirIndex As Integer = 0 502 | 503 | If Console.ForegroundColor = ConsoleColor.Red Then 504 | errorColor = ConsoleColor.Yellow 505 | End If 506 | 507 | ConsoleUtil.WriteColoredTextLine(" *F11*[+] *F14*Current User's PATH*F08*:*-F*" & Environment.NewLine, {"*"c}) 508 | 509 | If dirsCurrentUser IsNot Nothing Then 510 | 511 | For Each dir As String In dirsCurrentUser 512 | 513 | dirIndex += 1 514 | 515 | If IO.Directory.Exists(dir) Then 516 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F06*{0} *F08*= *F07*{1}*-F*", dirIndex.ToString("00"), dir), {"*"c}) 517 | Else 518 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F06*{0} *F08*= *F08*{1}*-F*", dirIndex.ToString("00"), dir), {"*"c}) 519 | 520 | End If 521 | 522 | Next dir 523 | 524 | dirIndex = 0 525 | 526 | End If 527 | 528 | Console.WriteLine() 529 | ConsoleUtil.WriteColoredTextLine(" *F11*[+] *F14*Local Machine PATH*F08*:*-F*" & Environment.NewLine, {"*"c}) 530 | 531 | If dirsAllUsers IsNot Nothing Then 532 | 533 | For Each dir As String In dirsAllUsers 534 | 535 | dirIndex += 1 536 | 537 | If IO.Directory.Exists(dir) Then 538 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F06*{0} *F08*= *F07*{1}*-F*", dirIndex.ToString("00"), dir), {"*"c}) 539 | Else 540 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F06*{0} *F08*= *F08*{1}*-F*", dirIndex.ToString("00"), dir), {"*"c}) 541 | End If 542 | 543 | Next dir 544 | 545 | End If 546 | 547 | End Sub 548 | 549 | ''' 550 | ''' Cleans the PATH and PATHEXT. 551 | ''' 552 | Private Sub Clean() 553 | 554 | Dim dirNotfoundtCurrentUserCount As Integer = 0 555 | Dim dirNotfoundAllUsersCount As Integer = 0 556 | 557 | Dim dirDupCurrentUserCount As Integer = 0 558 | Dim dirDupAllUsersCount As Integer = 0 559 | Dim extDupCurrentUserCount As Integer = 0 560 | Dim extDupAllUsersCount As Integer = 0 561 | 562 | Dim dirsCurrentPath As List(Of String) = 563 | PathUtil.GetPathDataList(PathUtil.UserMode.Current). 564 | Distinct(StringComparer.OrdinalIgnoreCase). 565 | OrderBy(Function(dir As String) dir). 566 | ToList() 567 | 568 | Dim dirsAllUsersPath As List(Of String) = 569 | PathUtil.GetPathDataList(PathUtil.UserMode.AllUsers). 570 | Distinct(StringComparer.OrdinalIgnoreCase). 571 | OrderBy(Function(dir As String) dir). 572 | ToList() 573 | 574 | Dim extsCurrentPath As List(Of String) = 575 | PathUtil.GetPathExtDataList(PathUtil.UserMode.Current). 576 | Distinct(StringComparer.OrdinalIgnoreCase). 577 | OrderBy(Function(ext As String) ext). 578 | ToList() 579 | 580 | Dim extsAllUsersPath As List(Of String) = 581 | PathUtil.GetPathExtDataList(PathUtil.UserMode.AllUsers). 582 | Distinct(StringComparer.OrdinalIgnoreCase). 583 | OrderBy(Function(ext As String) ext). 584 | ToList() 585 | 586 | ' ***************** 587 | ' current user's PATH 588 | ' ***************** 589 | Console.WriteLine() 590 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*Processing current user's PATH*F08*...*-F*" & Environment.NewLine, {"*"c}) 591 | 592 | dirDupCurrentUserCount = (PathUtil.GetPathDataList(PathUtil.UserMode.Current).Count - dirsCurrentPath.Count) 593 | 594 | For Each dir As String In dirsCurrentPath.ToArray 595 | 596 | If Not IO.Directory.Exists(dir) Then 597 | dirsCurrentPath.Remove(dir) 598 | dirNotfoundtCurrentUserCount += 1 599 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F07*Missing Directory Deleted: *F08*""*F06*{0}*F08*""*F07*.*-F*", dir), {"*"c}) 600 | End If 601 | 602 | Next dir 603 | 604 | ' ************** 605 | ' local machine PATH 606 | ' ************** 607 | Console.WriteLine() 608 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*Processing local machine PATH*F08*...*-F*" & Environment.NewLine, {"*"c}) 609 | dirDupAllUsersCount += (PathUtil.GetPathDataList(PathUtil.UserMode.AllUsers).Count - dirsAllUsersPath.Count) 610 | 611 | For Each dir As String In dirsAllUsersPath.ToArray 612 | 613 | If Not IO.Directory.Exists(dir) Then 614 | dirsAllUsersPath.Remove(dir) 615 | dirNotfoundAllUsersCount += 1 616 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F07*Missing Directory Deleted: *F08*""*F06*{0}*F08*""*F07*.*-F*", dir), {"*"c}) 617 | End If 618 | 619 | Next dir 620 | 621 | ' ******************** 622 | ' current user's PATHEXT 623 | ' ******************** 624 | Console.WriteLine() 625 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*Processing current user's PATHEXT*F08*...*-F*" & Environment.NewLine, {"*"c}) 626 | 627 | extDupCurrentUserCount += (PathUtil.GetPathExtDataList(PathUtil.UserMode.Current).Count - extsCurrentPath.Count) 628 | 629 | ' ***************** 630 | ' local machine PATHEXT 631 | ' ***************** 632 | Console.WriteLine() 633 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*Processing local machine PATHEXT*F08*...*-F*" & Environment.NewLine, {"*"c}) 634 | extDupAllUsersCount += (PathUtil.GetPathExtDataList(PathUtil.UserMode.AllUsers).Count - extsAllUsersPath.Count) 635 | 636 | ' *************** 637 | ' UPDAtE REGISTRY 638 | ' *************** 639 | PathUtil.CreatePath(PathUtil.UserMode.Current, String.Join(";"c, dirsCurrentPath)) 640 | PathUtil.CreatePath(PathUtil.UserMode.AllUsers, String.Join(";"c, dirsAllUsersPath)) 641 | PathUtil.CreatePathExt(PathUtil.UserMode.Current, String.Join(";"c, extsCurrentPath)) 642 | PathUtil.CreatePathExt(PathUtil.UserMode.AllUsers, String.Join(";"c, extsAllUsersPath)) 643 | 644 | ' ****** 645 | ' REPORT 646 | ' ****** 647 | Console.WriteLine() 648 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Removed *F06*{0} *F07*not found directories in current user's PATH.", dirNotfoundtCurrentUserCount.ToString("00")), {"*"c}) 649 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Removed *F06*{0} *F07*not found directories in local machine PATH.", dirNotfoundAllUsersCount.ToString("00")), {"*"c}) 650 | Console.WriteLine() 651 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Removed *F06*{0} *F07*duplicated directories in current user's PATH.", dirDupCurrentUserCount.ToString("00")), {"*"c}) 652 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Removed *F06*{0} *F07*duplicated directories in local machine PATH.", dirDupAllUsersCount.ToString("00")), {"*"c}) 653 | Console.WriteLine() 654 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Removed *F06*{0} *F07*duplicated extensions in current user's PATHEXT.", extDupCurrentUserCount.ToString("00")), {"*"c}) 655 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Removed *F06*{0} *F07*duplicated extensions in local machine PATHEXT", extDupAllUsersCount.ToString("00")), {"*"c}) 656 | Console.WriteLine() 657 | ConsoleUtil.WriteColoredTextLine(" *F11*[+] *F07*PATH and PATHEXT were successfully cleaned.*-F*", {"*"c}) 658 | 659 | End Sub 660 | 661 | ''' 662 | ''' Restores the defaults values for PATH and PATHEXT. 663 | ''' 664 | Private Sub RestoreDefaults() 665 | 666 | PathUtil.CreatePath(PathUtil.UserMode.Current, PathUtil.GetDefaultPathDataString) 667 | PathUtil.CreatePath(PathUtil.UserMode.AllUsers, PathUtil.GetDefaultPathDataString) 668 | 669 | PathUtil.CreatePathExt(PathUtil.UserMode.Current, PathUtil.DefaultPathExtData) 670 | PathUtil.CreatePathExt(PathUtil.UserMode.AllUsers, PathUtil.DefaultPathExtData) 671 | 672 | Console.WriteLine(" [+] PATH and PATHEXT were successfully restored to defaults.") 673 | 674 | End Sub 675 | 676 | #End Region 677 | 678 | #Region " PATHEXT Methods " 679 | 680 | ''' 681 | ''' Adds a file extension into the current user's PATHEXT. 682 | ''' 683 | ''' The file extension. 684 | Private Sub AddExtensionCurrentUser(ByVal ext As String) 685 | 686 | If Not PathUtil.PathExtExists(PathUtil.UserMode.Current) Then 687 | PathUtil.CreatePathExt(PathUtil.UserMode.Current) 688 | End If 689 | 690 | Select Case PathUtil.ContainsExtension(PathUtil.UserMode.Current, ext) 691 | 692 | Case True 693 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F12*[X] ERROR*F08*: *F07*""{0}"" already exists in current user's PATHEXT.*-F*", ext), {"*"c}) 694 | 695 | Case Else 696 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Adding *F07*""{0}"" into current user's PATHEXT...*-F*", ext), {"*"c}) 697 | PathUtil.AddExtension(PathUtil.UserMode.Current, ext) 698 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*File extension successfully added into current user's PATHEXT*-F*", {"*"c}) 699 | Console.WriteLine() 700 | 701 | End Select 702 | 703 | End Sub 704 | 705 | ''' 706 | ''' Adds a file extension into the local machine PATHEXT. 707 | ''' 708 | ''' The file extension. 709 | Private Sub AddExtensionAllUsers(ByVal ext As String) 710 | 711 | If Not PathUtil.PathExtExists(PathUtil.UserMode.AllUsers) Then 712 | PathUtil.CreatePathExt(PathUtil.UserMode.AllUsers) 713 | End If 714 | 715 | Select Case PathUtil.ContainsExtension(PathUtil.UserMode.AllUsers, ext) 716 | 717 | Case True 718 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F12*[X] ERROR*F08*: *F07*""{0}"" already exists in local machine PATHEXT.*-F*", ext), {"*"c}) 719 | 720 | Case Else 721 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Adding *F07*""{0}"" into local machine PATHEXT...*-F*", ext), {"*"c}) 722 | PathUtil.AddExtension(PathUtil.UserMode.AllUsers, ext) 723 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*File extension successfully added into local machine PATHEXT*-F*", {"*"c}) 724 | Console.WriteLine() 725 | 726 | End Select 727 | 728 | End Sub 729 | 730 | ''' 731 | ''' Deletes a file extension from the current user's PATHEXT. 732 | ''' 733 | ''' The file extension. 734 | Private Sub DeleteExtensionCurrentUser(ByVal ext As String) 735 | 736 | If Not PathUtil.PathExtExists(PathUtil.UserMode.Current) Then 737 | PathUtil.CreatePathExt(PathUtil.UserMode.Current) 738 | End If 739 | 740 | Select Case PathUtil.ContainsExtension(PathUtil.UserMode.Current, ext) 741 | 742 | Case False 743 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F12*[X] ERROR*F08*: *F07*""{0}"" doesn't exists in current user's PATHEXT.*-F*", ext), {"*"c}) 744 | 745 | Case Else 746 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Deleting *F07*""{0}"" from current user's PATHEXT...*-F*", ext), {"*"c}) 747 | PathUtil.DeleteExtension(PathUtil.UserMode.Current, ext) 748 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*File extension successfully deleted from current user's PATHEXT*-F*", {"*"c}) 749 | Console.WriteLine() 750 | 751 | End Select 752 | 753 | End Sub 754 | 755 | ''' 756 | ''' Deletes a file extension from the local machine PATHEXT. 757 | ''' 758 | ''' The file extension. 759 | Private Sub DeleteExtensionAllUsers(ByVal ext As String) 760 | 761 | If Not PathUtil.PathExtExists(PathUtil.UserMode.AllUsers) Then 762 | PathUtil.CreatePathExt(PathUtil.UserMode.AllUsers) 763 | End If 764 | 765 | Select Case PathUtil.ContainsExtension(PathUtil.UserMode.AllUsers, ext) 766 | 767 | Case False 768 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F12*[X] ERROR*F08*: *F07*""{0}"" doesn't exists in local machine PATHEXT.*-F*", ext), {"*"c}) 769 | 770 | Case Else 771 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F11*[i] *F07*Deleting *F07*""{0}"" from local machine PATHEXT...*-F*", ext), {"*"c}) 772 | PathUtil.DeleteExtension(PathUtil.UserMode.AllUsers, ext) 773 | ConsoleUtil.WriteColoredTextLine(" *F11*[i] *F07*File extension successfully deleted from local machine PATHEXT*-F*", {"*"c}) 774 | Console.WriteLine() 775 | 776 | End Select 777 | 778 | End Sub 779 | 780 | ''' 781 | ''' Lists the PATHEXT. 782 | ''' 783 | Private Sub ListPathext() 784 | 785 | Dim pathExtCurrentUser As IEnumerable(Of String) = PathUtil.GetPathExtDataList(PathUtil.UserMode.Current) 786 | Dim pathExtAllUsers As IEnumerable(Of String) = PathUtil.GetPathExtDataList(PathUtil.UserMode.AllUsers) 787 | Dim extIndex As Integer = 0 788 | 789 | Console.WriteLine() 790 | ConsoleUtil.WriteColoredTextLine(" *F11*[+] *F14*Current User's PATHEXT*F08*:*-F*" & Environment.NewLine, {"*"c}) 791 | 792 | If pathExtCurrentUser IsNot Nothing Then 793 | 794 | For Each ext As String In pathExtCurrentUser 795 | extIndex += 1 796 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F06*{0} *F08*= *F07*{1}*-F*", extIndex.ToString("00"), ext), {"*"c}) 797 | Next ext 798 | extIndex = 0 799 | 800 | End If 801 | 802 | Console.WriteLine() 803 | ConsoleUtil.WriteColoredTextLine(" *F11*[+] *F14*Local Machine PATHEXT*F08*:*-F*" & Environment.NewLine, {"*"c}) 804 | 805 | If pathExtAllUsers IsNot Nothing Then 806 | 807 | For Each ext As String In pathExtAllUsers 808 | extIndex += 1 809 | ConsoleUtil.WriteColoredTextLine(String.Format(" *F06*{0} *F08*= *F07*{1}*-F*", extIndex.ToString("00"), ext), {"*"c}) 810 | Next ext 811 | 812 | End If 813 | 814 | End Sub 815 | 816 | #End Region 817 | 818 | #Region " Miscellaneous Methods " 819 | 820 | ''' 821 | ''' Shows the specified program error. 822 | ''' 823 | ''' error Index. 824 | Private Sub DisplayError(ByVal errorIndex As Integer) 825 | 826 | Select Case errorIndex 827 | 828 | Case 1 ' /Add 829 | Console.WriteLine(" [X] ERROR: Please provide a directory to add.") 830 | Console.WriteLine() 831 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /add ""C:\Directory""") 832 | 833 | Case 2 ' /Add -user 834 | Console.WriteLine(" [X] ERROR: Please provide a directory to add.") 835 | Console.WriteLine() 836 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /add -user ""C:\Directory""") 837 | 838 | Case 3 ' /Add -machine 839 | Console.WriteLine(" [X] ERROR: Please provide a directory to add.") 840 | Console.WriteLine() 841 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /add -machine ""C:\Directory""") 842 | 843 | Case 4 ' /Del (String) 844 | Console.WriteLine(" [X] ERROR: Please provide a directory to delete.") 845 | Console.WriteLine() 846 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /del ""C:\Directory""") 847 | 848 | Case 5 ' /Del (Integer) 849 | Console.WriteLine(" [X] ERROR: Deletion by Entry Index is only allowed with -user and -machine parametters.") 850 | Console.WriteLine() 851 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /del -user 5") 852 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /del -machine 5") 853 | 854 | Case 6 ' /Del -user 855 | Console.WriteLine(" [X] ERROR: Please provide a directory to delete.") 856 | Console.WriteLine() 857 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /del -user ""C:\Directory""") 858 | 859 | Case 7 ' /Del -machine 860 | Console.WriteLine(" [X] ERROR: Please provide a directory to delete.") 861 | Console.WriteLine() 862 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /del -machine ""C:\Directory""") 863 | 864 | Case 8 ' /Export 865 | Console.WriteLine(" [X] ERROR: Please provide a File to export the data.") 866 | Console.WriteLine() 867 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /Export ""C:\Exported.reg""") 868 | 869 | Case 9 ' /AddExt 870 | Console.WriteLine(" [X] ERROR: Please provide a File-Extension to add.") 871 | Console.WriteLine() 872 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /AddExt "".PY""") 873 | 874 | Case 10 ' /DelExt 875 | Console.WriteLine(" [X] ERROR: Please provide a File-Extension to delete.") 876 | Console.WriteLine() 877 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /DelExt "".RB""") 878 | 879 | Case 11 ' /AddExt -user 880 | Console.WriteLine(" [X] ERROR: Please provide a File-Extension to add.") 881 | Console.WriteLine() 882 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /AddExt -user "".PY""") 883 | 884 | Case 12 ' /AddExt -machine 885 | Console.WriteLine(" [X] ERROR: Please provide a File-Extension to add.") 886 | Console.WriteLine() 887 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /AddExt -machine "".PY""") 888 | 889 | Case 13 ' /DelExt -user 890 | Console.WriteLine(" [X] ERROR: Please provide a File-Extension to delete.") 891 | Console.WriteLine() 892 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /DelExt -user "".RB""") 893 | 894 | Case 14 ' /DelExt -machine 895 | Console.WriteLine(" [X] ERROR: Please provide a File-Extension to delete.") 896 | Console.WriteLine() 897 | Console.WriteLine(" [i] EXAMPLE: PATHS.exe /DelExt -machine "".RB""") 898 | 899 | Case Else 900 | 901 | MsgBox("[ DEBUG ] Error de syntaxis al parsear parámetro: ""ErrorIndex""") 902 | Threading.Thread.Sleep(60) 903 | 904 | End Select 905 | 906 | Environment.Exit(1) 907 | 908 | End Sub 909 | 910 | ''' 911 | ''' Shows the program help. 912 | ''' 913 | Private Sub ShowHelp() 914 | 915 | Dim sb As New System.Text.StringBuilder 916 | sb.AppendLine(String.Format(" *F14*Author *F08*:*F07* {0}", HelpSection.ColorizedHelp..Value)) 917 | sb.AppendLine(String.Format(" *F14*Copyright*F08*:*F07* {0}", HelpSection.ColorizedHelp..Value)) 918 | sb.AppendLine(String.Format(" *F14*Website *F08*:*F07* {0}", HelpSection.ColorizedHelp..Value)) 919 | sb.AppendLine(HelpSection.ColorizedHelp..Value) 920 | sb.AppendLine(HelpSection.ColorizedHelp..Value) 921 | sb.AppendLine(HelpSection.ColorizedHelp..Value) 922 | sb.AppendLine(HelpSection.ColorizedHelp..Value) 923 | ConsoleUtil.WriteColoredTextLine(sb.ToString, {"*"c}) 924 | 925 | End Sub 926 | 927 | #End Region 928 | 929 | End Module 930 | 931 | End Namespace 932 | 933 | #End Region -------------------------------------------------------------------------------- /Solution/PATHS/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | --------------------------------------------------------------------------------