18.07.2019

Creating a program for windows yourself. We write programs (scripts) in Windows Notepad


As technology becomes more and more accessible to the general public, so does the need for programmers. Writing computer codes and programs, also known as coding (from the English "Coding"), is a skill that is acquired and improved over time, but even the most experienced programmer was once a beginner. There are a wide variety of programming languages ​​that are great for beginner programmers, no matter where you want to apply your skills. Learn how to learn how to write computer programs by reading this article.

Steps

Learn a programming language

    Don't worry too much about which language you should choose to learn. Many novice programmers find it difficult to choose a language when they first learn how to write code. The language itself, which you choose, does not matter when it comes to studying the structures and logic of building information. These skills are much more important and can be learned with any programming language.

    • When choosing a language, focus on the purpose for which you want to create program codes, and only then choose the initial language. For example, if you want to develop websites, then you should start by learning HTML and then expand it with CSS, JavaScript, and PHP. If you want to create programs for computers, then start learning C++ or any other major programming language.
    • If you become a professional programmer, you will quickly realize that you will never use the language you originally learned for your work. Instead, you will keep learning new languages ​​all the time through documentation and experimentation.
  1. Find free online resources for your chosen language. The Internet is a treasure chest of free tutorials, courses, and videos about the language you choose to learn. You can learn the basics of almost any introductory language in a day.

    • Here are just a few popular sites: Bento, CodeAcademy, Code.org, html.net, Khan Academy, Udacity, W3Schools, and many more.
    • wikiHow also has a wide variety of introductory tutorials for different languages.
    • You can find instructional videos for almost any language on YouTube.
    • Stack Exchange is one of the most popular forums where professional programmers answer any user questions.
  2. Download a good text editor. Many programming languages ​​allow the use of external text editors to write programs. Find a text editor that will display indentation and code markup.

    • Popular programs include Notepad++ (Windows), TextWrangler (OS X), and JEdit (any system).
  3. Download any necessary compilers. Some programming languages ​​require a compiler to display the source code you have written. Compilers translate source code into an equivalent low-level language program, which is then processed by the computer. Many compilers are open source and free programs. Languages ​​that require the use of compilers include:

    • BASIC
    • Fortran
    • Pascal
  4. Start your first project. Choose a good introductory project that will allow you to try out your new skills. There are many suggestions and tutorials on the Internet on this topic; for example, you can start by creating simple websites with HTML, simple databases and functions with PHP, or simple programs in any of the languages ​​that require the use of compilers.

    Consider the details of other programs or web projects. When you're learning to code on the go, don't be ashamed to look online for clues and see how other people solve similar problems. Take the time to understand why certain lines of code behave in certain ways.

    • Check out this guide to see how you can view the source code of any website.

Expand your knowledge

  1. Sign up for courses. Universities, colleges, and online programs offer certificates and courses that will not only teach you how to code, but also help you get a job. Although a university degree in programming is not always needed, it can help you find a permanent job as a programmer.

    • The benefit of direct communication with a teacher or a programming specialist, which is not always available through online courses, is undeniable.
    • Learning to be a programmer can cost you quite a bit, so think carefully if it's worth it. If you are into writing computer programs only as a hobby, you should not spend time and money on professional courses. If you want to build a career in this area, then getting a professional education can help you a lot (but, again, it is not necessary if you have talent).
  2. Expand your knowledge. You will benefit not only from studying programming languages, but also from courses in mathematics and logic, since these subjects often require high-level programming skills. You don't have to learn this at school or college, although such an environment can be helpful.

With this article, you will not learn how to program or even write a program as such, but you will find excellent VBS scripts and BAT files here, which you can write without any problems in a regular Windows notepad, you can improve it in your own way, then brag to friends and relatives. Perhaps this will cheer you up and you will have a great time.

Most of these scripts are written for the convenience and automation of any actions on a computer running Windows. The scripts presented below will not be very useful (maybe it seems to me), but they are great for an initial acquaintance with "coding". You will have a great time surprising both yourself and fellow dummies (not programmers), plus this is another a good option.

Some terminology:

  • VBS - programming language for creating scripts in Windows OS, created / edited in Windows Notepad, has permission ".vbs". I think it makes no sense to continue, because it will not tell you much, especially for beginners. Interested - .
  • BAT - a batch file, popularly just a "batch file". The file extension is ".bat". Further similarly -.

These extensions (vbs, bat) files are created in the well-known Windows Notepad (Notepad). For greater convenience in creating scripts, it is recommended to use an improved (let's say so) notepad - Notepad ++. It is convenient to highlight the syntax of a large number of programming languages, if it doesn’t tell you much, then download and write in it - you will make fewer errors in the code, or it will be easier to find them than in the same little functional Windows Notepad.

For clarity, an example (on the left - Windows Notepad, on the right - Notepad ++):


Let's get started

If you are already familiar with VBS scripts and batch files, then most likely the following examples will not be of interest to you, but if you are a beginner, then for the initial acquaintance - what you need.

Let's teach the computer to say hello

  1. Open Notepad (or Notepad Plus Plus).
  2. Copy to paste the code:

    Set sapi=CreateObject("sapi.spvoice")
    sapi.Speak "Hello!"

  3. Mandatory condition: quotes must be “such”, “Christmas trees” will not work, the script will not be processed and an error will occur. Instead of the word "Hello" you can write anything, even in Russian, if you have a Russian voice engine.
  4. Then select File - Save as - File type - All files - name.vbs
  5. Name the file whatever you want, but do not forget to add the extension - .vbs at the end (example - Privet.vbs).
  6. Now try to test your script - run the file by double-clicking.

One nuance: if you have written words in quotes in Russian letters, and at startup it is not clear what is pronounced, then you simply do not have a Russian voice engine installed. Detailed installation and configuration of the voice engine is beyond the scope of our article, so read it in more detail and come back here again.

Now, let's do the following: write this script to autoload, which means that when you start the computer, the word (s) written in the program will be pronounced to you, if, as in the example, it will say "Hello" every time the computer is turned on. How to do it?

It's simple, you can add a program (script) to startup in the same way, that is, through the same VBS script. Create a file in notepad, copy/paste (Ctrl+C/Ctrl+V) the following code:

Dim vOrg, objArgs, root, key, WshShell
root = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\"
KeyHP="Program"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite root+keyHP,"C:\Privet.vbs /autorun"

We change the path to the "talker" script, this line - C:\Privet.vbs to our own. We prescribe where you have this script and what it is called. Next, save the newly created mini program in notepad and run it. Everything, now the computer will greet you every time you turn it on.

Open drive

  1. Open notepad. Copy/Paste the following code:

    Set a = CreateObject("WMPlayer.OCX.7")
    Set b = a.CdromCollection
    Set c = b.Item(0)
    Set d = c.Eject

  2. Save with .vbs extension
  3. Run the script and the drive will open.

There is a more interesting modification of this script:

Set WMPlayer = CreateObject("WMPlayer.OCX.7")
do
WMPlayer.CdRomCollection.Item(0).Eject()
loop

In this case, the CD / DVD drive will open and close all the time, on laptops in this case it will open after each closing.

Attention! The second code (opening/closing the drive) is seen by some antiviruses as a malicious program. Kaspersky Anti-Virus (including and) sees it exactly like that and destroys it immediately. In the first case (just opening the drive) for antivirus programs is not a malicious script.

To stop automatically opening/closing the drive:

  1. Launch Task Manager (- Ctrl+Alt+Del).
  2. Go to the "Processes" tab.
  3. Find the wscript.exe process - right mouse button - end the process.

A game

An interesting find from the Web is a game on VBS. It is necessary to guess a number from 0 to 100. The script automatically sets (guesses) the number that you need to guess and enter in a special box when you start the script; if the answer is wrong, hints are given, for example, less or more.

Below is the same code that you need to copy and paste into notepad, then save (extension.vbs).

You can also change messages in your own way, everything that is written in Cyrillic is edited without problems. Don't be afraid to break the code. Experiment. In which case, copy the working code from here again.

Set y = CreateObject("Scripting.FileSystemObject")
Set y = Nothing
Do
a = 0
u = 0
Randomize
Number = Int((RND*99)+1)
MsgBox "I guessed a number from 1 to 100, try guessing",64,"Guess"
Do
a = a + 1
c = InputBox("Guess the number" & vbCrLf & vbCrLf & "Try: " & a & vbCrLf & vbCrLf & "Enter number to see results!" & vbCrLf & vbCrLf & "Leave empty to exit" & vbCrLf & vbCrLf," Guessing")
If c = "!" Then CreateObject("WScript.Shell").Run "notepad C:\Windows\Result.dll",3,True: Exit Do
If c<>"" Then
If IsNumeric(c) = True Then
If CInt(c)< Number Then MsgBox "Нет,это не " & c & ". Я загадал число больше",64,"Угадайка"
If CInt(c) > Number Then MsgBox "No, it's not " & c & ". I guessed a number less than",64,"Guess"
If CInt(c) = Number Then
Set y = CreateObject("Scripting.FileSystemObject")
MsgBox ("Number of attempts: " & a)
If MsgBox("That's right, it was the number "&c&". Start over?",36,"Guess") = 6 Then Exit Do Else WScript.Quit
End if
Else
MsgBox "That's not a number!",16,"Guess"
a = a - 1
End if
Else
a = a - 1
l = MsgBox ("You didn't enter anything. Exit the program?",36,"Guess")
If l = 6 Then WScript.Quit
End if
loop
loop

Well, before moving on to batch files (.BAT), let's use the most useful VBS script from all those listed in this article.

Script to close wscript.exe

The script itself:

Set TaskKill = CreateObject("WScript.Shell")
TaskKill.Run "TaskKill /f /im wscript.exe"

In fact, it does the same thing that was explained a little higher in the task manager, for example, you can’t just take and close the annoying script that opens and closes the drive, and by running this script, all running ones will be closed. It's like a wedge is knocked out with a wedge.

We got a little acquainted with VBS scripts and how to write them in a notepad, now let's look at a few examples of using BAT files (hereinafter referred to as the batch file).

A very simple batch file consisting of just one line.

  1. Open Notepad.
  2. We write the following code:

    shutdown -s -t 1 -c -f

  3. Next File - Save as - name.bat
  4. Pay attention to the file extension, this is no longer a VBS script, but a batch file, so we write .bat at the end of the name (Example compoff.bat).
  5. We launch the newly created batch file by double-clicking and the computer will turn off (Shutdown).

There is a code like this:

shutdown -r -t 1 -c -f

Everything is the same, we write it in a notepad, save it with the .bat extension and after starting the computer will reboot (normal computer restart).

Removing updates

This batch file is useful if you already. What is the point? This batch file lists commands for removing several updates, as the name implies - telemetry updates, or just one of the system's spyware, we once said how to turn it off, in this case you just create a batch file, copy the code below into the content and run , after which the listed updates will be removed.

@echo
echo
echo Step 1: Delete Updates Telemetry
wusa /uninstall /kb:3068708 /quiet /norestart
wusa /uninstall /kb:3022345 /quiet /norestart
wusa /uninstall /kb:3075249 /quiet /norestart
wusa /uninstall /kb:3080149 /quiet /norestart

Thus, you can remove absolutely any update, even annoying KB971033 which checks .

There are many different scripts on the Internet that are supposedly harmless, but be careful before trying which script is not clear, some of them can do harm, for example, make changes to the registry, and in case of any errors the system will give errors, in which case you will have to either Windows Or do a system restore.

Do you want to learn how to program? You don't need fancy software; You can work with any programming language in Notepad. The functionality is not too wide, but great for batch files and testing other small programs. You can create a simple program in a few minutes, but for more complex software products, you may want to consider a more advanced editor.

Steps

Part 1

Using Notepad to Program in Any Language

Part 2

Create a batch file

    Learn basic batch commands. Notepad is very often used to create batch files. Batch files are programs that are used for automatic functions in command line. You can use batch files to apply changes to a large number of files at once, create backups, and more.

    • Below are the simplest examples of batch programs.
  1. Write a simple backup program. This simple program is able to back up files from one folder to another, copying only those files that have changed since the last backup.

    Write a batch file to test your network. If you want to test your network or internet connection, this batch file will display information from the Ipconfig and Ping commands.

    Save the file in .bat format. When you create a batch file in Notepad, you will have to save it as a .bat file. The file will become executable, which is launched by double-clicking the mouse or using the command line.

    • Click on File - Save As. Select "All Files (*.*)" from the "Save as Format" context menu. Enter permission.bat. The file will be saved as a batch file, allowing it to be run.
  2. Create your own batch files. You can do a lot with batch files. You can add delays, create a file compression program, add a password, and more.

    • Search the web for more information on working with and creating batch files.

Part 3

Creating a Python Program
  1. Learn basic Python scripting. Python is a popular programming language for web scripting and one of the easiest languages ​​to learn. Python programs don't have to be complex; you will need an installed interpreter. Most Python programs work through a command line interface.

    • Below you can see some simple Python file examples.
  2. Create a "Hello, World" program. This is the easiest program to create and teaches you the basics of building Python programs. The program displays the words "Hello, World!" on the user's screen.

    Output the Fibonacci sequence. This simple program counts Fibonacci numbers up to 100. You can change the value of 100 (on the second line) to whatever you want. Don't forget to include indentations - that's how functions are denoted in Python.

    Start your programs. You don't need to compile Python programs to run them. If you have an interpreter installed, then you can run the saved file to run the program. Click on File - Save As. Select "All Files (*.*)" from the "Save as Format" context menu. Enter the “.py” permission. In this way, the interpreter will be able to recognize and run the desired file.

  3. Create other Python programs. Even if you are not very familiar with the language, Python is a very powerful programming language that will help you create many useful things. You will be able to create lists, loops and graphs. You can even create a game using Python.

    • Search the Internet for more information on working and creating programs in Python.