Visual Basic 2010 Read/Write Command Prompt

Visual Basic Online Course - Command Prompt

Read / Write Windows Command Prompt from VB 2010

Read / Write Windows Command Prompt from Visual Basic 2010

Command Prompt

A command prompt is an entry point for typing computer commands in the Command Prompt window. By typing commands at the command prompt, you can perform tasks on your computer without using the Windows graphical interface.

Command Prompt Commands

ADDUSERS Add or list users to/from a CSV file
ARP Address Resolution Protocol
~ ASSOC Change file extension associations
ASSOCIAT One step file association
AT Schedule a command to run at a later time
ATTRIB Change file attributes

BOOTCFG Edit Windows boot settings
BROWSTAT Get domain, browser and PDC info

CACLS Change file permissions
~ CALL Call one batch program from another
~ CD Change Directory - move to a specific Folder
CHANGE Change Terminal Server Session properties
CHKDSK Check Disk - check and repair disk problems
CHKNTFS Check the NTFS file system
CHOICE Accept keyboard input to a batch file
CIPHER Encrypt or Decrypt files/folders
CleanMgr Automated cleanup of Temp files, recycle bin
CLEARMEM Clear memory leaks
CLIP Copy STDIN to the Windows clipboard.
~ CLS Clear the screen
CLUSTER Windows Clustering
CMD Start a new CMD shell
~ COLOR Change colors of the CMD window
COMP Compare the contents of two files or sets of files
COMPACT Compress files or folders on an NTFS partition
COMPRESS Compress individual files on an NTFS partition
CON2PRT Connect or disconnect a Printer
CONVERT Convert a FAT drive to NTFS.
~ COPY Copy one or more files to another location
CSCcmd Client-side caching (Offline Files)
CSVDE Import or Export Active Directory data

~ DATE Display or set the date
Dcomcnfg DCOM Configuration Utility
DEFRAG Defragment hard drive
~ DEL Delete one or more files
DELPROF Delete NT user profiles
DELTREE Delete a folder and all subfolders
DevCon Device Manager Command Line Utility
~ DIR Display a list of files and folders
DIRUSE Display disk usage
DISKCOMP Compare the contents of two floppy disks
DISKCOPY Copy the contents of one floppy disk to another
DISKPART Disk Administration
DNSSTAT DNS Statistics
DOSKEY Edit command line, recall commands, and create macros
DSADD Add user (computer, group..) to active directory
DSQUERY List items in active directory
DSMOD Modify user (computer, group..) in active directory

~ ECHO Display message on screen
~ ENDLOCAL End localisation of environment changes in a batch file
~ ERASE Delete one or more files
~ EXIT Quit the current script/routine and set an errorlevel.
EXPAND Uncompress files
EXTRACT Uncompress CAB files

FC Compare two files
FIND Search for a text string in a file
FINDSTR Search for strings in files
~ FOR /F Loop command: against a set of files
~ FOR /F Loop command: against the results of another command
~ FOR Loop command: all options Files, Directory, List
FORFILES Batch process multiple files
FORMAT Format a disk
FREEDISK Check free disk space (in bytes)
FSUTIL File and Volume utilities
FTP File Transfer Protocol
~ FTYPE Display or modify file types used in file extension associations

GLOBAL Display membership of global groups
~ GOTO Direct a batch program to jump to a labelled line

HELP Online Help 

~ IF Conditionally perform a command
IFMEMBER Is the current user in an NT Workgroup

KILL Remove a program from memory


LABEL Edit a disk label
LOCAL Display membership of local groups
LOGEVENT Write text to the NT event viewer.
LOGOFF Log a user off
LOGTIME Log the date and time in a file


MAPISEND Send email from the command line
MBSAcli Baseline Security Analyzer.
MEM Display memory usage
~ MD Create new folders
MKLINK Create a symbolic link (linkd)
MODE Configure a system device
MORE Display output, one screen at a time
MOUNTVOL Manage a volume mount point
~ MOVE Move files from one folder to another
MOVEUSER Move a user from one domain to another
MSG Send a message
MSIEXEC Microsoft Windows Installer
MSINFO Windows NT diagnostics
MSTSC Terminal Server Connection (Remote Desktop Protocol)
MUNGE Find and Replace text within file(s)
MV Copy in-use files

NET Manage network resources
NETDOM Domain Manager
NETSH Configure network protocols
NETSVC Command-line Service Controller
NBTSTAT Display networking statistics (NetBIOS over TCP/IP)
NETSTAT Display networking statistics (TCP/IP)
NOW Display the current Date and Time
NSLOOKUP Name server lookup
NTBACKUP Backup folders to tape
NTRIGHTS Edit user account rights

~ PATH Display or set a search path for executable files
PATHPING Trace route plus network latency and packet loss
~ PAUSE Suspend processing of a batch file and display a message
PERMS Show permissions for a user


1) Copy / Paste filesCopy - This command allows you to copy files from one location to another. To use this command you would type
copy filetocopy copiedfile
For example if you have the file D:\test\test.txt and would like to copy it to c:\windows\test.txt you would type
copy D:\test\test.txt c:\windows\test.txt
and press enter. 
If the copy is successful it will tell you so and give you back the prompt. If you are copying within the same directory you do not have to use the path. 

Here are some examples and what they would do:
copy File.txt ThisFile.bak     Copies the File.txt file to a new file called ThisFile.bak in the same directory
copy File.txt \windows     Copies the File.txt file to the \windows directory.
copy * \windows     Copies all the files in the current directory to the \windows directory.


Re-directors are an important part to using the command prompt as they allow you to manipulate how the output or input of a program is displayed or used. Re-directors are used by appending them to the end of a command followed by what you are redirecting to. For example: Dir > DirOutPuts.txt. There are four re-directors that are used in a command prompt and they are discussed below:

>     This re-director will take the output of a program and store it in a file. If the file exists, it will be overwritten. If it does not exist it will create a new file. For example the command dir > DirOutPuts.txt will take the output of the Dir command and place it in the DirOutPuts.txt file. If dir.txt exists, it will overwrite it, otherwise it will create it.

>>     This re-director will take the output of a program and store it in a file. If the file exists, the data will be appended to the current data in the file rather than overwriting it. If it does not exist it will create a new file. For example the command dir >> dir.txt will take the output of the dir command and appends it to the existing data in the Dir.txt file if the file exists. If dir.txt does not exist, it will create the file first.

<     This re-director will take the input for a program from a specified file. For example the date command expects input from a user. So if we had the command date < date.txt, it would take the input for the date program from the information contained in the date.txt file.

|     This re-director is called a pipe. It will take the output of a program and pipe it into another program. For example Dir | sort would take the output of the dir command and use it as input to the sort command.

How do we use of those info in Visual Basic 2010 ?

There are so many benefits of using Command Prompt Commands in VB 2010, I will give an example of comparing two EXE file (Windows Application) using FC command from VB 2010 which I know is needed most by many developers, there are some tools that actually do that and are based on the usage of FC command.

Example : Compare two applications is called Binary Diff. , FC command operate a comparison process based on the location of the two *.exe files and return the result like this :
xxxxxx: yy zz
The value of xxxxxx specifies the relative hexadecimal address for the pair of bytes, measured from the beginning of the file. Addresses start at 00000000.
The hexadecimal values for yy and zz represent the mismatched bytes from filename1.exe and filename2.exe , respectively.

Syntax :
FC  [drive1:][path1]filename1.exe [drive2:][path2]filename2.exe /B
[drive1:][path1]filename1 : Specifies the location and name of the first file you want to compare. Filename1 is required.
[drive2:][path2]filename2 : Specifies the location and name of the second file you want to compare. Filename2 is required. 
/B  : Compares the files in binary mode. FC compares the two files byte by byte and does not attempt to resynchronize the files after finding a mismatch. This is the default mode for comparing files that have the following file extensions: .exe, .com, .sys, .obj, .lib, or .bin.

To make use of the example :
Create any Visual Basic 2010 Project [Windows Form]
Build it, so you would have an EXE file in Bin\Debug
Copy the exe file to another Dir called C:\Comp, and rename it to (CS.exe)
Edit your Visual Basic 2010 Source Code (Add any line of code)
Build menu : Clear Solution
Build menu : Build solution
now you have another version of the exe file
Rename your recent exe file (Cexe.exe) and paste it in C:\Comp folder with the previous exe file
Now you have 2 different exe (CS.exe and Cexe.exe) files in C:\Comp folder and we want to compare them as Binary Diff.

Create new VB 2010 Project, like this :
VB 2010 Command Prompt
Compare two windows applications in VB 2010 using Command Prompt FC Command
Name : form1
Caption : Compare two exe files
'Contains the command Line FC
Name : TextBox1
MultiLine : True
Text :
@Echo Off
FC C:\comp\CS.exe C:\comp\Cexe.exe /B
'Will contain the Comparison result of the two EXE application files.
: TextBox2
MultiLine : True
Text :Comparison Result will display here ...
'Executes the Command Line FC in the TextBox1
Name : Button1
Text : Go

Visual Basic Code : Open code area, clear it and paste the following codes ....

Run your application. The result will be like this :
VB 2010 Binary Diff example
Comparison Result of Comparing two windows applications using FC command from VB 2010
You can extend your work further and further ..... If you have any questions please comment. Thank you for reading Visual Basic Online Course - Command Prompt

Here are some online Visual Basic lessons and courses :

OOP Toturial Index Polymorphism VB 2010 VB 2010 Optimization object oriented programming OOP Crystal Report Freelance Optimization VB 2010 MS-Access 2003/2007 ADO.Net visual basic course Crystal report and VB .net Earn money programming - Programmer Jobs Online Online courses VB2010 Receive E-mail Search Optimization Sql Server Visual Basic Visual Basic 2010 online courses Visual Basic Job online visual basic courses pop server pop3 visual basic courses online visual basic online courses ADO.Net online mode Insert Date into SqlServer using VB.Net Install Crystal report No error message available SqlServer VB 2010 DataGridView Visual Basic .Net and SQL Server Date-Time Visual Basic .net Visual Basic Class connecting to access database via dao using database e-mail .net framework 4.5.2 Activate Visual Studio 2005 Advantage Data Dictionary Advantage Database Visual Basic 2010 Binary Diff Buttons sound in VB 2010 CR for VS2015 CRforVS2015 Check internet connection Command Prompt Communicate with a client Compare two applications Compare two strings and return differences Compare two treeviews Conversion from type 'DBNull' to type 'String' is not valid Crystal Report with Protected MS-Access database DAO + VB .NET + ACCESS DataGridView VB 2010 Programming DataGridView with MS-Access DataReader DevExpress 12.2.9 Serial crack full DevExpress VB.Net DevExpress full Download DevExpress 12 Dxperience 12.2.4 Dxperience full serial crack Event Planning Example on connecting to Advantage Data Dictionary from VB.Net FC Command Fade Image VB 2010 MS Access 2010 MS SQL SERVER 2000 INSTALLATION MS VB.Net MS-Access 2007 2010 MS-Access Compact and Repair from VB 2010 Programmatically Make sure application is running Microsoft Visual Basic .Net Math Functions list OOP Lesson 11 OOP Lesson 12 OOP Lesson 6 OOP Lesson 7 OOP Lesson 8 OOP Lesson 9 OOP Lesson13 OOPTutorials POP3 Commands in VB 2010 Point of sale application Purchase Receive E-mail from Gmail in VB 2010 Requirement Doc Reverse Strings SQL Server 2000 SQL Server 2000 date-time type Sales and Stores application Source code download Sql Server and VB.Net The Microsoft.ACE.OLEDB.12.0 provider is not registered on the local machine The following control could not be licensed There is already an open DataReader associated with this Command which must be closed first Toolbox items Topmost - Inputbox Sloved Tx TxtControl for Visual Basic Use case definition VB 2005 Activation Code VB 2010 Compare and return differences VB 2010 Create Controls at Run-Time with events VB 2010 How to fade Image VB 2010 Internet VB 2010 Read Text Files VB 2010 Reverse Strings VB 2010 check for internet connection VB 2010 database compact and repair VB 2010 progressbar VB.Net Math functions VB.Net Search Optimization SqlServer 2000 lessons VB2010 VS 2051 VS2010 VS2015 VS2017 VS2019 Virus W32.Sality Visual Basic Application Development Visual Basic Virus Visual Studio Serial Number book classes vb compare windows applications and return the difference. crystalDecision older version download crystal report for VB 2010 dtSearch dtSearch Engine dtSearch Engine download full free free make sure application is installed object oriented programming languages oop Lesson 10 play sounds in Visual progress bar result code: DB_SEC_E_AUTH_FAILED(0x80040E4D). sqlserver2000 project (new-save-edit-delete) the application failed to initialize properly 0xc000007b tutorials vb .Net functions list. vb 2010 Create TextBox with events at Project Runtime vb 2010 receive Emails visual basic .Net FlexGrid visual basic courses win10 32 bit solution برنامج المشتريات و المبيعات و المخازن
Show more