May 12th, 2015
Many applications create files for logging the functionality and errors occurred during operation. There are times the log files are not cleaned up and start to accumulate within a folder on the operating system. Using the “forfiles” command to reduce the number of files in a directory (folder) for faster indexing (listing) of files in Windows 7, 8 and Windows Server 2008, 2008 R2, 2012, 2012 R2, and 2014.
Running nightly backups of websites to an external USB drive reduces the space on the drive since every backup is being retained for archive purposes. The files are compressed to save space, but accumulate due to no cleanup module. Using the “forfiles” command from the command line, in Task Manager, or within the actual backup script will reduce the number of files within the directories (folders).
Note: Forfiles will only accept single arguments for search criteria, so if the directory (folder) has multiple search criteria, in the nightly backup example there are both .tar and .bak files that need to be removed, so you will need to perform a loop within a batch file.
Note: Be careful with wildcard characters like “*” and “?” since forfiles will bypass the recycle bin.
Note: This is a way to delete files from the command line or a batch file and not a way to bypass other deletion methods. Explorer.exe will consume CPU and memory while running so consider running forfiles during off-hours.
Note: Test forfiles with a non-intrusive command like dir to examine the files selected before running forfiles command section with a dir command.
- Open a command prompt by typing cmd in the search or run text boxes in Windows.
- At the command line type forfiles /? and press Enter
- If you receive the message “forfiles is not recognized as an internal or external command, operable batch file or program” the means the environmental path is not in the path statement on the PC or server.
- 64 bit system: C:\Windows\System32\forfiles
- Use the full path in the command (recommended for automated tasks) or add the path to the Environmental Variables – Path statement
- Let us analyze the following command: “forfiles /P L:\Backups\MyWebsite\ /M *.tar /D -200 /C “cmd /c del @file”
- /P is the path directive. In the example the folder is on the L: disk and under the Backups folder.
- /M is the search pattern. The search pattern should be as close to finding the files that the command will execute against.
- /D is the date for the files that will be acted against by the command. In this example -200 means delete any files with a .tar extension that is over 200 days old.
- /C is the actual command. “cmd /c del @file” is what will be executed against any .tar files that are over 200 days old in the L:\Backups\MyWebsite\ folder.
- /S **CAUTION** with this flag. This means recursive and will follow into subdirectories within the main directory. This could have undesirable effects and should be tested with a non-final command like “cmd /c dir @file”. Taking the previous command “forfiles /P L:\Backups\ /S /M *.tar /D -200 /C “cmd /c del @file” will delete all TAR files over 200 days old in any folder under L:\Backups.
- Logging in forfiles can be accomplished by creating a log file, like forfiles /P L:\Backups\ /S /M *.tar /D -200 /C “cmd /c del @file” >> C:\temp\myfiles.txt
This is a small example of what the forfiles command can do to clean up large number of files on a Windows system.
November 26th, 2014
Problem: V-79-10000-11226 – VSS Snapshot error. The Microsoft Volume Shadow Copy Service (VSS) snapshot technology selected returned: “Unexpected provider error”. Ensure that all provider services are enabled and can be started. Check the Windows Event Viewer for details.
The following volumes are dependent on resource: “C:” .
Analysis: Since this was a VSS writer issue on a Windows 2008 R2 server, the first thing I ran was “vssadmin list writers” to see what writers were failing. The failing writers were all Windows system writers like the WMI Writer. So I re-registered the writers running a batch script, but you can accomplish the same thing by restarting the server. Read the rest of this entry »
November 18th, 2014
If you are using the G++ compiler in Linux, CentOS, or Redhat there are a couple of steps to adding a random number generator to any project.
- Include the precompile library: #include <stdlib.h>
- Use the function and add seeding: first_number = rand()%6 +1);
The basic function in C++ for the G++ compiler in Linux looks like this:
int first_number = rand()%6 +1;
std::cout << first_number;
November 11th, 2014
Starting a Microsoft Visual C++ Studio Console Application
- Open Microsoft Visual C++ 2010 Express
- In the menu go to File – New – Project
- Click on Visual C++ and highlight Win32 Console Application
- Give the new project a name, default directory, and Solution Name
- Click OK and another GUI will pop-up
- On the Welcome to the Win32 Application Wizard click Next >
- On the Application Settings remove the check box from Precompiled Header and check Empty
- Click Finish
- When the new project opens right click on Source Files
- Go to Add – New Item…
- When the wizard opens highlight C++ File (.cpp) and give it the name of main.cpp
- Click Add
- Enter the following in the main.cpp file
Place your code after the first curly brace and before the return 0; to get started. Happy coding.
November 2nd, 2014
If you are like me you work on your computer or use it to play games in the evening to alleviate stress. However, once you are finished using the computer you forget to turn if off. Now, for many this does not seem to be a problem but consider other aspects of leaving a computer running.
- Someone could gain access to a laptop webcam and see that no one is home or spy on people in the room.
- If you accidentally get a virus the PC which can turn it into a zombie or join it to a botnet. So while you are away your PC is working in the background.
- Some people just never turn the PC or laptop off because he or she feels the power saving options are sufficient.
- The amount that all the electronic devices are costing you per month in your electric bill.
Let’s examine the fourth possibility because it happened to me. My average electric bill when my kids were at home was $125 per month. When they left for college the electric bill dropped to $95 per month. When I deployed the shutdown script on my PC the electric bill dropped to $69 per month. Saving over $50 a month (you could save more) on your electric bill seems like a pretty good idea to me.
Read the rest of this entry »
November 1st, 2014
Here is a nice video showing how to set up LPD print services in Windows so you can share a non-networkable printer on the network.
October 10th, 2014
This is a very common issue if you are sending email with multiple invoice or statement attachments.
If you are using IIS 6 Smart Host to relay email:
- Open Internet Information Services (IIS) 6 Manager
- Expand the default domain
- Right click on the [SMTP Virtual Server #1] and select properties
- Click on the messages tab in increase the following:
Limit message size to (KB): default is 2048 so increase it to 20480
Limit session size to (KB): default is 10340 increase it to at least the size of the Limit message size.
- Click OK and resend the email.
If you are sending directly to your SMTP provider check with them to see what the message size limits are because many will set that to 2 MB like Google Applications. The reason for the limit is so the SMTP server does not get bogged down trying to scan the email with spam filter and processing large requests.
Hope this helps.
August 25th, 2014
They have been experiencing electrical storms over the past couple of weeks. When I went into Backup Exec the tape drive was offline. I brought the tape drive back online and ran a tape erase to test and it was successful. Sometime just restarting all the Backup Exec services works just as well.
August 14th, 2014
An information technology disaster can be defined as any event or series of events which halt the production capability of any information system. An organization deletes an Excel spreadsheet being used to keep track of sales or inventory is a disaster. Another organization has a fire in the data center and due to fire suppression techniques the server hardware is damaged is a disaster. Regardless of the physical magnitude, it a system’s production capability is lost the organization has suffered a disaster.
Every organization needs to define information technology disasters within each information technology system in use. Evaluations can take the form of hiring a Systems Analyst or even brainstorming. Identify the systems that if lost, will result in halting production capabilities within the organization. Refrain from passing judgment at this time since the emphasis is on identification and not change.
Read the rest of this entry »
March 30th, 2014
Creating groups in Google Applications can create a group for documentation collaboration and email. Creating a group for email means that the members will not be visible to the recipients
- Log into your Google Applications account using an Administrator account.
- With the new Dashboard find the Groups – “Manage groups of users and mailing lists”
- Click on the Groups section
- Click on the shortcut located towards the upper right hand corner of the page to create a new group.
- On the Create new group page enter the following:
- Name of the group – A name to call the group.
- Group email address – Email address that the group will use. This cannot be an email address that already exists within the Google Applications domain.
- Access Level – I generally keep this at the team level so that users can send email to the group but cannot see the members.
- Click Create
- Once the group is created you will be redirected to the group’s application page.
- To add users to the group click on Manage users in (name of group)
- In the Add new members section entry the email addresses you want in the group. The email address does not have to be a member of the domain.
- Once you have added the members press the Add button.
- NOTE: At any time you can add all members of the domain to the group. This is very important if you are considering adding an email group for all employees or students if the domain is for a school.
- Once the users have been added you can exit the group and test within an email client by sending email to the group email address.
- You can also add other groups to the new group by adding the group email address to the newly created group.
- Restrict Ability to Send Email to the Group – You can restrict the ability to send email to the group by setting the owner as the only one who can send email. What that does is restrict the ability to “Reply to” and for unauthorized personnel from using the group email address to spam the members of the group. This can be set up by clicking on the new group – Role and permissions – Custom and removing the check mark from all by the Owner group. Click Save changes
Hope you enjoyed this brief overview of creating groups in Google Application. If you have any questions please let me know and I will be happy to answer them.