Vbscript creating many folders

March 9, 2010

Very good vbscript if you need to create folders. In my cause i had to create for example in Archive folder many little subfolders from 001,002,..010,011…099,100 to 300.

ParentFolder = “C:\Archive”
set objShell = CreateObject(“Shell.Application”)
set objFolder = objShell.NameSpace(ParentFolder)
FOR i=1 to 9
objFolder.NewFolder “00”+CStr(i)
FOR i=10 to 99
objFolder.NewFolder “0”+CStr(i)
FOR i=100 to 300
objFolder.NewFolder CStr(i)


How to remove files from folder with VBScript

March 9, 2010

Here is the script. It is usefull for example if you need to remove old backup files from a folder or some old log files. The only thing is to put it to task schedule. Here is the script:

Dim Fso

Dim Directory

Dim Modified

Dim Files

Set Fso = CreateObject(“Scripting.FileSystemObject”)

Set Directory = Fso.GetFolder(“C:\inetpub\logs\logfiles\W3SVC3”)

Set Files = Directory.Files

For Each Modified in Files

If DateDiff(“D”, Modified.DateLastModified, Now) > 30 Then Modified.Delete


So some explanations

Set Fso = CreateObject(“Scripting.FileSystemObject”) //create file system objct

Set Directory = Fso.GetFolder(“some path”) //this is the actual folder which will be searched for files

For Each Modified in Files //this is the actual loop for every file in the directory

If DateDiff(“D”, Modified.DateLastModified, Now) > 30 Then Modified.Delete //here you should set how log the files will be keeped. 30 in this example means if  the files is more than 30 days old then delete it. The funktion compares every file with today date and in this cause if today is 30 days more than date of some file it deletes it.

After that make a simple task schedule with cscript <some filename.vbs>. This will run script in command line.

Here there is some slightly different modification of the script. If somebody wonders how the script could be modified in that manner, that it can remove old files (or data) from subfolder beneath some root folder. Here is the modified script.

Let’s say we have the followind scenario. We have Microsoft SQL server 2008 and a maintenance plan which takes care of backups. All backups have been made in a folder called D:\SQL Backups.

In addition to the above script i will introduce a variable  Dim Subdirectory. In that cause we have Directory and Subdirectory variables. The difference is the line Set SubDirectory = Directory.Subfolders. Whith that line Subdirectory variable gets all subdirectories underneath. f1 is some kind of subsidiary variable represent object to access to every file in every subdirectory.

Dim Fso

Dim Directory

Dim Modified

Dim Files

Dim SubDirectory

Dim f1

Set Fso = CreateObject(“Scripting.FileSystemObject”)

Set Directory = Fso.GetFolder(“D:\SQL Backups”)

Set SubDirectory = Directory.Subfolders

For Each f1 in Subdirectory

Set Files = f1.Files

For Each Modified in Files

If DateDiff(“D”, Modified.DateLastModified, Now) > 3 Then Modified.Delete



Some very useful sites about Debian Linux

February 25, 2010

http://www.debian.org – Official documentation.

http://www.aboutdebian.com/ – Very good site for the beginners. It is very good for starting point about various administrative tasks.

http://wiki.debian.org/ – Useful guides about administration and many others

http://forums.debian.net/ – forums

http://www.debian-administration.org/ – Very good information about maintaining and administering

http://www.debianadmin.com/ – Just another very good source about administration, howtos tips

http://wiki.debian.org/DebianLive/Howto/USB – If you need some USB bootable Debian system you may have to take a look at this site.

http://debianhelp.co.uk/ – Very good one


Error synchronizing outlook with CRM 4.0

February 25, 2010

A SQL server error occurred. Try this action again. if the problem continues, check the microsoft dynamics CRM community for solution or contact your… This is an issue which is appearing by installation of Rollup 7 for CRM 4.0.

The story is that i ‘ve installed successfuly CRM 4.0 and after that installed Rollup 7,8 and 9. After some checks i realized that when i tried to synchronize CRM for outlook it gives me a SQL server error. The solution is really simple. In my cause i had up to the latest rollup 9 installed until this moment on my server. What ive’ done is uninstall all rolups one by one. First uninstalled Rollup 9 then restart the server. After that i’ve uninstalled rollup 8 and then restarted again the server. Finally i’ve uninstalled rollup 7. When i tested CRM for outlook it worked perfectly without any Rollups. Now i only installed Rollup 9 and tested. With rollup 9 without any previous rollups it works fine.

When you try to access the Server from localhost by it’s FQDN or CNAME repeatedly pops up for cridentials

February 24, 2010

This is about the folowing situation. I have one vitual PC for testing purposes. For example the machine is called Server01.domain.local. I have one local site hosted on it . A simple site writted on ASP.Net or Sharepoint site. It doesn’t matter. It has windows integrated authentication. I have a host header for example mysite.somedomain.com. It works perfectly from Internet. I have the host header name in local hosts file too. When i tried to browse that from local machine (mysite.somedomain.com) it pops up repeatedly for cridentials.

This happened with IIS 6.0 in windows server 2003 with sp1 or sp2. In windows server 2008 the behaviour is the same.

The solution is:


New multistring value called


Right click modify and add host headers if there are more. In this cause i add


 The full article http://support.microsoft.com/kb/926642


Microsoft DPM Server does not remove old recovery points (after expiration of retention period)

February 22, 2010

I have been using DPM of about 6 months until now. The story is that i have of about 4 DPM 2007 production servers. I have various protection groups which protects databases,file system, system state e.t.c. 

After creation of that protection groups everything seemed fine. But after a month ago I kept running out of free space of recovery point volumes for every member of the particular protection group. What I’ve done is that I had some free space on my storage which is used by DPM and every time I increased free space of that particular member. For example I have protection group for database server SRV1 which includes three protected databases db1, db2, db3. I was keeping recovery points for 7 days. Finally I discovered that there are recovery points on Recovery tab of DPM for the whole month. It wasn’t keeping them only for 7 days. The solution I found is to delete the old recovery points manually through PowerShell.  Although there are many sources for that, here is my guide how to do delete them.

1.List of dpm protection groups
get-protectiongroup Srv1

2.Store the output in variable $pglist

$pglist=get-protectiongroup Srv1
output only to count 0,1,2,3,4…

Foreach($pg in $pgList){write-host($pg.FriendlyName)}  // this is only for to see display of members

so you should count members of the protection group always from 0 after that 1,2,3 e.t.c

Db1  -count 0

DB2 -count 1

DB3 -count 2

the statement above will print out the list of protection group in your DPM
server. the first protection group should be referred to $pglist[0], the second one
should be referred to as $pglist[1] and so on

3.Get the source of protected group

$dslist = get-datasource($pglist[X]) for example 6

check to see if you have more than one data source by issuing this command:
write-host $dslist.name if you are not getting any output this means that there are multiply data source. For example in DB1 i have multible data sources every 15 minutes because i’ve made synchronization with consistency check every 15 minutes. If this is the cause you need to select which one you are going to use.

foreach($ds in $dslist){write-host $ds.name}

master -1

model -2

DB1 -3

For Example i want to delete recovery points from DB1 which is count 3.

4. Get recoverypoints

get-recoverypoint $dslist[3]       //only to verify 

The output is something like:

DB1 12-1-2010 1:05:09   SRV1\DB1… Disk //count 0
DB1 13-1-2010 1:05:41   SRV1\DB1… Disk //count1
DB1 14-1-2010 1:05:48   SRV1\DB1… Disk
DB1 15-1-2010 11:55:40  SRV1\DB1… Disk
DB1 15-1-2010 11:59:42  SRV1\DB1… Disk
DB1 16-1-2010 1:06:43   SRV1\DB1… Disk
DB1 17-1-2010 1:05:28   SRV1\DB1… Disk
5. Optional step for review only

$rplist=get-recoverypoint $dslist[x] example 0
foreach($rp in $rplist){write-host $rp.representedpointintime}

12-1-2010 1:05:09 //count 0
13-1-2010 1:05:41 //count 1
14-1-2010 1:05:48 //count2
15-1-2010 11:55:40
15-1-2010 11:59:42

5.Remove recovery points
remove-recoverypoint -recoverypoint $rplist[x]  //0,1,2 and so on

Here is the whole simple script:

get-protectiongroup SRV1
$pglist=get-protectiongroup SRV1
Foreach($pg in $pgList){write-host($pg.FriendlyName)}
$dslist = get-datasource($pglist[1])
write-host $dslist.name
foreach($ds in $dslist){write-host $ds.name} //count which recovery point you should delete from 0,1,2
get-recoverypoint $dslist[4]
$rplist=get-recoverypoint $dslist[4]
foreach($rp in $rplist){write-host $rp.representedpointintime}
remove-recoverypoint -recoverypoint $rplist[0]

Here is the othe approach. If  write-host $dslist.name outputs some result here is the steps need to be taken.

write-host $dslist.name

systemstate – this is an example

$rplist=get-recoverypoint $dslist

foreach($rp in $rplist) {write-host $rp.representendpointintime}

remove-recoverypoint -recoverypoint $rplist[0]  //and $rplist[1],2 and so on

or if it refjuses to delete recovery points

remove-recoverypoint -recoverypoint $rplist[0] -ForceDeletion