Monday, March 25, 2013

Clean AVG Temporary Files via Batch File

AVG is a great free antivirus quite popular among the users of Dr.Batcher. You can find it here. But as every software, it leaves sometimes some temporary files that should be cleaned manually by its user. Batch files are the best way to clear AVG temporary files.
Here is a small batch file that will help you to clean AVG temporary files:
CD "C:\Program Files (x86)\AVG\AVG8\"
avgcfgex.exe /command=19
CD C:\ProgramData\avg8\scanlogs
DEL C:\ProgramData\avg8\scanlogs\*.* /s /q
MD C:\ProgramData\avg8\scanlogs
CD C:\ProgramData\avg8\update\backup
DEL C:\ProgramData\avg8\update\backup\*.* /s /q
MD C:\ProgramData\avg8\updata\backup
ECHO Successfully Deleted All AVG Temp Update Files...
PAUSE

We kindly remind that Dr.Batcher is the best program to create batch file, try it if haven't tried it yet.

Friday, March 22, 2013

Windows Scripting Technologies: Create Batch File vs. Write in Other Scripting Languages





Introduction
So what is special about these technologies that they should be looked at separately? Frankly speaking, the answer to this question lies in the title of this article; being the most popular operating system, Windows gets special attention from its users.
Although script technologies are often cross-platform, it doesn’t down-grade their interest, value and attractiveness. I’d rather say, the situation is even quite opposite. But let’s not run before the hounds and speak about the technologies themselves. And after that we’ll classify them and decide what exactly in each of them troubles the user.


Batch files
Batch files were the pioneers among script technologies available for Windows-users. Specifically, they became available even before the creation of Windows, in DOS-deep times. And as POSIX system fans like to notice nowadays, their founding fathers were aspired by the shell scripts that have become wide-spread in UNIX. Nevertheless, it’s not that important to know what exactly inspired the programmers to create such a popular and useful technology which made the users’ lives easier in the times when fast typing was a vital skill for everyone.
The years went by. Batch files became obsolescent, and Windows developers offered more powerful and more sophisticated script technologies. But none of them could fully substitute batch files. Why? Batch files are thought to be a live continuation of command line which is used both by simple users and system administrators. That is why the Microsoft corporation is still releasing command line utility suits that can be used in batch files automation, and it doesn’t plan to put out batch files support in its future system versions to promote more powerful and advanced technologies.
Nowadays, batch files have a number of advantages over other script technologies. First, it’s easy to create them. Actually, providing that you’re not trying to solve a tricky problem with batch files, the batch file itself consists of ten lines where you write commands or call command line utilities. Anyone can create batch file, and if you use some specific utilities like Dr. Batcher (http://www.drbatcher.com) the whole process becomes even simpler. The second advantage is its portability. If you don’t use specific commands or utilities that work only under certain system versions, your batch file can run in all Windows versions.  But of course, if to try implementing complex automation with batch files, you can be disappointed as they’ve been designed for solving comparatively small automation problems. 


KiXtart
This script language was developed by a member of the dutch Microsoft division and initially was designed to automize the users’ work with Microsoft LAN Manager. But much water has flowed under the bridges since then and today KiXtart (www.kixtart.org) is a totally independent script language that interacts with COM-objects and, therefore, with such COM-based technologies as ADSI, ADO, and WMI. One of the most pleasant things of KiXtart is its FiXforms library which gives you the possibility of creating a fully functional graphical user interface. Moreover, opposed to batch files, KiXtart was initially tailored for more complex tasks and, therefore, it can carry out custom functions that are wide-spread over the Internet. So among the major advantages of this technology are GUI support, and a flexible combination of simplicity and power that attracts both real users and system administrators.


Active Scripting
In contrast to KiXtrat, this technology implies the use of completely different programming languages and natively proposes VBScript and Jscript. Usually the end-user deals with Active Scripting using the possibilities of Windows Script Host (WSH). First it appeared in Windows’98 and has been used very actively since.
Of course, Active Scripting provides broader options than batch files. Languages used in script writing handle with objects and give access to COM-based technologies. With WSH you can use login-scripts, manipulate the registry, and do a lot of other useful and interesting things. It isn’t that you can’t do all this with batch files, but by using Active Scripting you don’t have to bend your mind that hard. And also it doesn’t require deep knowledge of both the language and other third-party tools.
In addition to VBScript and Jscript, Active Scripting supports other languages used in other platforms and popular among Windows system administrators. I’m sure you’ve heard of such software programmes as ActivePerl, ActivePython, ActivePHP... Yes, they are the very implementations of well-known script programming languages compatible with Active Scripting. This feature of Active Scripting technology happens to be the most attractive as everyone has their own preferences in the context of programming languages, and such kind of democracy that let you use your favourite language is definitely heartily welcomed by users.
As for the tools that make possible script writing over Active Scripting, there are lots of them. And each programming language has its own tools. As the most popular scripting language for Active Scripting is the Windows native VBScript, then most applications you’ll find will be VBScript applications. To my mind, one of the most handy editors is VBSEdit. But of course it doesn’t mean that some another similar software product won’t suit your taste.


Windows PowerShell
Just as Active Scripting replaced batch files (well, it didn’t fully replace them; it’s rather become a more powerful and professional add-on), so too PowerShell changed Active Scripting. Microsoft actively promotes a new script technology and it has acquired quite a good reputation among users and system administrators.
While Active Scripting is COM-based, in PowerShell the next generation of Microsoft technologies is used, that is .NET. Among PowerShell scripts you can turn to .NET instances just as you turned to COM objects. By the way, it doesn’t mean that you can’t use COM objects anymore. PowerShell scripts are based on cmdlets. Practically, these are small sections of a code or even complete programmes that implement some located and separate task. Despite their essence, cmdlets can be of a different nature. Some of them may be Windows native program files, others – PowerShell scripts or even COM- and .NET –objects methods.
All in all, PowerShell does have a number of significant advantages over Active Scripting. In some way these advantages are provided by .NET platform and Microsoft .NET Framework libraries, and in another they lie in the possibilities of PowerShell script platform itself.  On the whole, we can say that PowerShell successfully pushes VBScript and other languages out, but it isn’t likely to completely replace batch files as they are in different leagues and go together quite peacefully.
What concerns tools for editing PowerShell scripts, they are also numerous. Besides already mentioned AdminScriptEditor, there exist such tool as PowerShellAnalyzer and PowerGUI.

Other script technologies
Certainly, there are other non-specific for Windows script technologies which are popular among system administrators and users to this or that degree. Some of them also transferred from other platforms but were not of interest to ActiveState company that adjusted many script languages to Active Scripting. Some of them were created by enthusiasts and commercial companies… So, there are lots of script technologies and we can’t look at all of them. We’ll just name them but won’t go into details.

Summary
So which one of Windows script technologies is the best? It’s difficult to say. Even after enumerating the peculiarities each of them. It is because they are rather different, and each one has its own advantages and disadvantages. It’s irrational to automize a simple task with Windows PowerShell, but it’s silly to turn to batch files for a complex automation either. So we can say that each technology is appropriate in its own field of use.
Roger Vadey
Expert in batch files programming. Exactly know how to create batch file in a fast and proper way.

Monday, March 18, 2013

How to Merge Two Files with Help of Batch Script

Imagine: you have some spiltted files and you want to merge them into the new file containing all of them. Of course, it is much simpler to perform this operation using a small batch script instead of copying data manually. Here you can see an example of this batch script (hope, it'll be quite understandable with the comments):
REM Advanced Files Merger
REM Adds files specified by mask to the end of the file passed as the first parameter
REM Masks or names of files to be added are passed as the second, the third, etc. parameters
REM E.g. usage is like: merger FileToBeExpanded.bin *.exe *.zip *.*
@ECHO off
IF '%1=='LooP   GOTO %2
SET prgname=%0
SET destfile=%1
IF '%2=='   GOTO done
IF not EXIST %2  GOTO done
:_loop
SHIFT
IF '%1=='   GOTO done
FOR %%i in (%1) do CALL %prgname% LooP addfile %%i
GOTO _loop
:addfile
type %3>>%destfile%
echo.>>%destfile%
:done

We kindly remind that Dr.Batcher is the best program to create batch file, try it if haven't tried it yet.

Tuesday, March 12, 2013

How to Find Desktop from Batch File

Sometimes it is necessary to operate with some files on desktop. It is easy to find a desktop itself :), but how to get the path to from a batch script? Here is a small bath script that might help you with this task.
ECHO chcp 1251 > 11.cmd
FOR /f "skip=4 tokens=2,*" %%i in ('reg query "HKCU\software\microsoft\windows\currentversion\explorer\shell folders" /v desktop') do ECHO set desktop=%%j >> 11.cmd
ECHO chcp 866 >> 11.cmd
CALL 11.cmd
ECHO %desktop%

As far as you can see, we retrieve the desktop location from Windows registry. The only trick is to process characters in different encodings, thus we need to create a temporary batch file.
We kindly remind that Dr.Batcher is the best program to create batch file, try it if haven't tried it yet.

Translate