Last active
September 23, 2019 11:14
-
-
Save CRUZEAAKASH/f1e0796a37d6bac395ff67b837c6d484 to your computer and use it in GitHub Desktop.
VB Script Commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''''''''''''''''''''''''''''''''''''''''''''' | |
'''''''1. To take user input | |
'''''''''''''''''''''''''''''''''''''''''''' | |
name = inputbox("Enter your name Please:") | |
By this command a message box will pop up to enter the name | |
2. To print the output on Console - use Echo | |
WScript.Echo "name=" + name | |
#################################################################################### | |
#################To Deal with File System Objects, i.e, to move,copy,delete/filepath etc, declare Filesystem objects | |
#################################################################################### | |
3. To get the path of current script present in the system | |
Set FSO = CreateObject("Scripting.FileSystemObject") | |
path_of_script = WScript.ScriptFullName | |
WScript.Echo path_of_script | |
4. To get the path of parent folder | |
Set FSO = CreateObject("Scripting.FileSystemObject") | |
path_of_script = WScript.ScriptFullName | |
path_of_parent = FSO.GetParentFolderName(vbsFile) | |
5. to find the position value of a substring at its first occurrence inside the main string | |
stringA = Hello World, What are you doing?" | |
location_of_comma = Instr(stringA, ",") | |
WScript.Echo location_of_comma ===>12 | |
6. To get the specified number of characters from left side | |
stringB = left(stringA, 10) | |
WScript.Echo stringB ====>Hello Worl | |
7. LCase is used to convert the specified string into a lower case. | |
LCase(name of the string) | |
8. UCase is used to convert the specified string into upper case. | |
UCase(name of string) | |
9. Len is used to get the length of a specified String | |
Len(Name of string) | |
10. Replace is used to replace the specified portion of a string with some other text as specified. | |
Replace(name of the string, name of the string to be replaced, name of the new replaced string) | |
eg : Replace("H.e.l.l.o W.O.r.l.d", ".", "_") | |
output = > H_e_l_l_o W_o_r_l_d | |
11. StrReverse is used to reverse the specified string i.e. this will return the characters of a specified string in a reverse order starting from end to the beginning. | |
StrReverse(name of the string) | |
12. To Delete a file | |
first check if the file is present. If yes, then only you will be able to delete the file | |
Set FSO = CreateObject("Scripting.FileSystemObject") | |
if FSO.FileExists(Path of file to be deleted) | |
FSO.DeleteFile sFile, True | |
End If |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment