I break it down into several separate parts, since each part can be done individually. (I see a similar answer, but I will provide a more detailed explanation here.)
The first part , to avoid entering "CScript" (or "WScript"), you need to tell Windows how to run the * .vbs script file. In my Windows 8 (I cannot be sure that all these commands work exactly as shown here on old Windows, but the process is the same, even if you need to change the commands a little), start a console window (for example, "command line" , or aka [wrong] "dos prompt") and enter "assoc.vbs". This should lead to an answer, for example:
C:\Windows\System32>assoc .vbs .vbs=VBSFile
Using this, you then type "ftype VBSFile", which should lead to the answer:
C:\Windows\System32>ftype VBSFile vbsfile="%SystemRoot%\System32\WScript.exe" "%1" %*
-OR -
C:\Windows\System32>ftype VBSFile vbsfile="%SystemRoot%\System32\CScript.exe" "%1" %*
If the two are already defined as described above, your Windows is already configured to know how to run the * .vbs file. (BTW, WScript and CScript are the same program using different names. WScript runs the script as if it were a GUI program, and CScript runs it as if it were a command line program. See Other Sites and / or documentation for these details and cautions.)
If any of the commands did not respond as described above (or similar answers, if the file type reported by the association and / or the command executed with the ftype message has different names or locations), you can enter them yourself:
C:\Windows\System32>assoc .vbs=VBSFile
th / or -
C:\Windows\System32>ftype vbsfile="%SystemRoot%\System32\WScript.exe" "%1" %*
You can also type "help assoc" or "help ftype" to get more information about these commands, which are often convenient when you want to automatically run certain programs by simply typing a file name with a specific extension. (Be careful, as some file extensions are specially configured by Windows or by programs that you might have installed to work correctly. Always check the current assigned values reported by assoc / ftype and save them in a text file somewhere if you need to restore them.)
The second part , without entering the file extension when entering a command from the console window. Understanding how Windows (and the CMD.EXE program) finds the commands you enter is useful for this (and the next) part. When you enter a command, let's use "querty" as an example, the system will first try to find the command of the internal list of commands in it (through the settings in the Windows registry for the system itself or programmed in the case of CMD.EXE). Since there is no such command, it will try to find the command in the current environment variable% PATH%. In older versions of DOS / Windows, CMD.EXE (and / or COMMAND.COM) will automatically add the file extensions ".bat", ".exe", ".com" and possibly ".cmd" to the name of the command you printed if you have not explicitly typed the extension (for example, "querty.bat" to avoid the error "querty.exe" by mistake). On more modern Windows, it will try the extensions listed in the% PATHEXT% environment variable. So all you have to do is add .vbs to% PATHEXT%. For example, here is my% PATHEXT%:
C:\Windows\System32>set pathext PATHEXT=.PLX;.PLW;.PL;.BAT;.CMD;.VBS;.COM;.EXE;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY
Note that extensions MUST include ".", Separated by a ";" and that .VBS is displayed in the "AFTER .CMD" field, but BEFORE .COM. This means that if the shell (CMD.EXE) finds more than one match, it will use the first of these. That is, if I have query.cmd, querty.vbs and querty.com, it will use querty.cmd.
Now, if you want to do this all the time without having to install% PATHEXT%, you will have to change the system environment. Entering it in the console window only changes it for the console window session. I will leave this process to the reader. :-P
The third part is to run the script without typing the full path. This part, related to the second part, has existed since DOS. Just make sure the file is in one of the directories (folders for you, Windows people!), Listed in the% PATH% environment variable. My suggestion is to make your own directory for storing various files and programs that you create or often use from the console / command line window (that is, do not worry about this for programs that you start from the start menu or any other method ..only a console window.Do not mess with programs that are installed by Windows or the automatic installer if you don’t know what you are doing).
Personally, I always create the "C: \ sys \ bat" directory for batch files, the "C: \ sys \ bin" directory for * .exe and * .com files (for example, if you download something like "md5sum", the utility checksum MD5), the directory "C: \ sys \ wsh" for VBScripts (and JScripts with the name "wsh", since both are executed using the "Windows Scripting Host" or "wsh"), and soon. Then I add them to my% PATH% variable (control panel → advanced system settings → Advanced tab → environment variables), so Windows can always find them when you type them.
Combining all three parts will lead to the configuration of your Windows system so that wherever you can enter a command line command, you can run your VBScript by simply typing its base file name. You can do the same for any type of file / extension; As you probably saw in my% PATHEXT%, my system is set up to run Perl (.PLX; .PLW; .PL) and Python (.PY) scripts. (I also put "C: \ sys \ bat; C: \ sys \ scripts; C: \ sys \ wsh; C: \ sys \ bin" at the beginning of my% PATH% and put various batch files, script files, etc. e. in these directories, so Windows can always find them. It is also convenient if you want to "redefine" some commands: first put the * .bat files in the path so that the system finds them before *. exe, for example, and then the file * .bat can run a real program by providing the full path to the actual * .exe file. Find out about the various sites in “batch file programming” for more information and other examples of powerful STI command line .. It's not dead!)
Last comment:. Check out some of the other sites for various warnings and cautions. This question was posed by a script called "converter.vbs", which is dangerously close to the "convert.exe" command, which is a Windows program to convert your hard drive from the FAT file system to the NTFS file system. which can compress your hard drive if you make a text entry error.
On the other hand, using the above methods, you can also isolate yourself from such errors. As an example, you can use CONVERT.EXE. Rename it to something like "REAL_CONVERT.EXE", then create a file like "C: \ sys \ bat \ convert.bat" that contains:
@ECHO OFF ECHO !DANGER! !DANGER! !DANGER! !DANGER, WILL ROBINSON! ECHO This command will convert your hard drive to NTFS! DO YOU REALLY WANT TO DO THIS?! ECHO PRESS CONTROL-C TO ABORT, otherwise.. REM "PAUSE" will pause the batch file with the message "Press any key to continue...", REM and also allow the user to press CONTROL-C which will prompt the user to abort or REM continue running the batch file. PAUSE ECHO Okay, if you're really determined to do this, type this command: ECHO. %SystemRoot%\SYSTEM32\REAL_CONVERT.EXE ECHO to run the real CONVERT.EXE program. Have a nice day!
You can also use CHOICE.EXE on modern Windows so that the user enters "y" or "n" if they really want to continue, etc. Again, the power of batch (and script) files!
Here are some links to some good resources on how to use all this power:
http://ss64.com/
http://www.computerhope.com/batch.htm
http://commandwindows.com/batch.htm
http://www.robvanderwoude.com/batchfiles.php
Most of these sites are focused on batch files, but most of the information in them is used to run any type of file (* .bat), command file (* .cmd) and scripts (* .vbs, * .js, * .pl, *. py, etc.).