AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Vbs script debugger11/29/2023 ![]() Personally, I always create a "C:\sys\bat" directory for batch files, a "C:\sys\bin" directory for *. Don't mess with programs that are installed by Windows or an automated installer unless you know what you're doing). My suggestion is to make your own directory to store various files and programs you create or use often from the console window/command prompt ( that is, don't worry about doing this for programs you run from the start menu or any other method. Simply make sure the file is in one of the directories (folders, for you Windows' folk!) listed in the %PATH% environment variable. This part, in relation to the second part, has been around since the days of DOS. Third part, getting the script to run without always typing the full path. I'll leave this process as an exercise for the reader. Typing it in a console window only changes it for that console window session. Now, if you want to do this all the time without having to keep setting %PATHEXT%, you'll have to modify the system environment. That is, if I have query.cmd, querty.vbs and, it'll use querty.cmd. This means that if the command processor (CMD.EXE) finds more than one match, it'll use the first one listed. Notice that the extensions MUST include the ".", are separated by " ", and that. For example, here's my %PATHEXT%: C:\Windows\System32>set pathext In more modern Windows, it will try the extensions listed in the %PATHEXT% environment variable. In older versions of DOS/Windows, CMD.EXE (and/or COMMAND.COM) would automatically add the file extensions ".bat", ".exe", ".com" and possibly ".cmd" to the command name you typed, unless you explicitly typed an extension (such as "querty.bat" to avoid running "querty.exe" by mistake). Since there is no such command, it will then try to find the command in the current %PATH% environment variable. When you type a command, let's use "querty" as an example command, the system will first try to find the command in it's internal list of commands (via settings in the Windows' registry for the system itself, or programmed in in the case of CMD.EXE). Understanding how Windows (and the CMD.EXE program) finds commands you type is useful for this (and the next) part. Second part, avoiding typing the file extension when typing the command from the console window. Always check the currently assigned values reported by assoc/ftype and save them in a text file somewhere in case you have to restore them.) ![]() (Be careful though, as some file extensions are specially set up by Windows or programs you may have installed so they operate correctly. You can also type " help assoc" or " help ftype" for additional information on these commands, which are often handy when you want to automatically run certain programs by simply typing a filename with a specific extension. and/or- C:\Windows\System32>ftype vbsfile="%SystemRoot%\System32\WScript.exe" "%1" %* If either of the commands did not respond as above (or similar responses, if the file type reported by assoc and/or the command executed as reported by ftype have different names or locations), you can enter them yourself: C:\Windows\System32>assoc. See other sites and/or documentation for these details and caveats.) ![]() ![]() WScript launches the script as if it were a GUI program, and CScript launches it as if it were a command line program. (BTW, WScript and CScript are the same program, using different names. If these two are already defined as above, your Windows' is already set up to know how to launch a *. Vbsfile="%SystemRoot%\System32\CScript.exe" "%1" %* Vbsfile="%SystemRoot%\System32\WScript.exe" "%1" %* Using that, you then type " ftype VBSFile", which should result in a response of: C:\Windows\System32>ftype VBSFile That should result in a response such as: C:\Windows\System32>assoc. In My Windows 8 (I cannot be sure all these commands work exactly as shown here in older Windows, but the process is the same, even if you have to change the commands slightly), launch a console window (aka "command prompt", or aka "dos prompt") and type " assoc. (I see the similar answer, but I'm going to give a more detailed explanation here.)įirst part, in order to avoid typing "CScript" (or "WScript"), you need to tell Windows how to launch a *. I'll break this down in to several distinct parts, as each part can be done individually. ![]()
0 Comments
Read More
Leave a Reply. |