I’ve got a c# app that I’ve developed, and am now trying to compile on my new system I’ve had a few problems, biggest one being at the line: ‘NotesSession session = new NotesSession();’ ….I’m sure it compiled ok on my last system..hm!
I get the error….CLSID {blahblah} failed with error 80040154.
Turns out that Visual studio was compiling for “Any CPU”, this needs changing to x86, as the notes COM objects don’t do the x64 shizzle. All makes sense now, as new laptop is 64-bit!!
App now works and I’m a bit happier!
Posted in Programming
When trying to access a windows server via a DNS alias (e.g. using \\fileserver.company.co.uk that is an alias of \\SERVER12), you will probably get a ‘duplicate name exists on the network’ error. This is because the default behaviour of windows only permits using the proper name of the server (SERVER12 in this case, or a bound IP address). This applies to both CNAMEs and A records in DNS.
You might have aliases set up so that if you ever move a service onto a different server, all you have to do is update the alias.
To enable a windows server to respond to aliases like this, you’ll need to edit the registry. Navigate to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters
Then add a new DWORD value, called DisableStrictNameChecking and the the value to 1.
Once this is done, you’ll need to restart the server service, after that you should be able to access the server using the alias name!
Posted in Networking, OS
In Windows 7, it’s been annoying me for a while how the windows explorer item on the taskbar always default to my libraries, as on most systems I use they are empty.
You can change the location by holding shift and right clicking on the taskbar item so you can select properties in the context menu (If you’ve already got explorer windows open, you’ll need to right click the taskbar item once, then hold shift and right click on the Windows Explorer entry.)
Once in the properties window, if you set the target to the following, it will open ‘My Computer’ by default…
%SystemRoot%\explorer.exe /e,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
Posted in OS
Over the last few days, I have been having a lot of problems trying to write Lotus Notes .NET applications in Windows Vista. I had no problems writing the apps under XP, but since upgrading I kept getting error messages like “Unable to find user id file” when trying to initiate a Notes Session. The problem was with Windows Vista Virtual Store!
Installing Lotus Notes on Windows Vista, seems to be a normal installation. But when you launch Lotus Notes for the first time, it will start to write the notes.ini file and your id file (plus some other user related files…) to the following location: C:\Users\username\AppData\Local\VirtualStore\Program Files\lotus\. I never realised this before, until a colleague told me that Lotus Notes wrote files to this folder! With Lotus Notes writing to this folder, it made my .NET applications stop working!
The way to fix this, is to browse to: C:\Program Files, right click on “lotus”, go to the security tab and Edit the permissions for “Users” to Full Control. Apply the security settings. If you then copy the lotus folder from the VirtualStore to the normal Program Files folder, you will not lose any of your setting:
Copy: C:\Users\username\AppData\Local\VirtualStore\Program Files\lotus\ To: C:\Program Files
You should now be able to delete the lotus folder from the VirtualStore (or just rename the lotus folder to lotus.old if you are worried about losing the data – this would be useful to see Lotus Notes recreates the folder in the VirtualStore).
Lotus Notes should now not use the Virtual Store, and your .NET apps should run without any error.
Posted in Apps, Tips
Shadow copies are a brilliant time-saver… I can recover a deleted/overwritten/corruped file in a matter of seconds – or better still, the end user can do it! We currently have a schedule that takes a snapshot of our main fileserver at 7am and noon. While this is quite good, it quickly eats up diskspace, then all the snapshots get ditched and we have to start collecting them again. I wished there was some more complex scheduling and management for the shadows - I would find it far more useful to have more of the recent snapshots, and less of the older ones. Unfortunatly there’s no inbuilt functionality to do this, so I thought it was time to write a script…
I put together the following, it looks through all the snapshots on the system, and will delete those that match the following criteria:
- Older than 3 days and created after 7am
- Older than 7 days and not created on a Monday
- Older than 31 days
Scheduled to run daily, it should work a treat. The amount of snapshots should also stay constant, as once they are older then 31 days they will be removed.
option explicit
Dim objWMI, snapshots, snapshot, sDate, vDate, deleteSnapshot
Set objWMI = GetObject("winmgmts://localhost/root/cimv2")
Set snapshots = objWMI.ExecQuery("select * from Win32_ShadowCopy")
set sDate = CreateObject("WbemScripting.SWbemDateTime")
WScript.echo "Searching for all snapshots..."
for each snapshot in snapshots
sDate.Value = snapshot.InstallDate
vDate = sDate.GetVarDate(True)
WScript.echo vbCrLf & "Found snapshot... Created " & vDate
'WScript.echo snapshot.VolumeName
if (DateDiff("d", vDate, Date) > 7) then
if (DatePart("w", vDate) <> 2) then
WScript.echo "Older than 7 days & Not created on a Monday"
deleteSnapshot = true
end if
end if
if (DateDiff("d", vDate, Date) > 3) then
if (hour(vDate) > 7) then
WScript.Echo "Older than 3 days & Created after 7AM"
deleteSnapshot = true
end if
end if
if (DateDiff("d", vDate, Date) > 31) then
WScript.Echo "Older than 31 days"
deleteSnapshot = true
end if
if (deleteSnapshot) then
WScript.echo "*** Deleting snapshot ***"
snapshot.Delete_()
deleteSnapshot = false
else
WScript.echo "*** Keeping snapshot ***"
end if
next
Posted in OS, Scripting
When creating a some system inventory groups in Altiris, I noticed that it didn’t seem to be collecting information for certain exe’s that had been deployed onto the system.
After a bit of reading, I found out the the software audit scan can run in two modes… Package and file mode. In package mode, it only reports on a single exe from each package, which makes reporting faster and keeps your Altiris database much smaller. This is what runs from a vanilla installation. The second type of can is file scan, where every exe is audited, you can set this by editing ‘AeXInvSolnAdm2.ini ‘ in the NSCap folder to run the following:
AeXAuditPls.exe /file /hidden /output xml
You’ll have to wait a day or two for all your systems to re-run the inventory, but after you should be able to report on alot more!
Posted in Apps, Tips
During migration to our new one of our new firewalls, I became aware that our outbound mail was not getting out and the queue was just growing. After a bit of digging around I found that our internal mail server could establish a SMTP connection to the server it was trying to send to, the message just wasn’t going down the connection.
I telnet’ed to the SMTP server that we were trying to deliver to, to try and manually send a message by issuing SMTP commands, the conversation went something like the following:
RECV> 220 ****2************************************
SEND> HELO mail. squiggle.org
RECV> 500 5.5.1 Command unrecognized: “XXXX”
Every command that I issued resulted in not being recognised, but each letter substituted as XX’s. After a bit more investigation (netcat listning on port 25 to see what was really being sent), it became apparent that something was altering the SMTP commands, and also the server header on the initial 220 by the looks of it.
After looking into what could be making these alterations, I found out that the likly culprit was our newly configured Cisco PIX firewall… Cisco fixup can run on a firewall and inspect the data in a SMTP session, to try and secure it more, by restricting it to a certain commandset, ours just looked to be restricting the whole lot! Disabling the fixup for SMTP with the following command fixed the issue:
> no fixup protocol smtp 25
As soon as this rule was added, mail started flowing again!
Posted in Networking
I came across a peculiar issue today with Lotus Notes 7, running on my newish Vista system, I was doing some c# development with the Notes COM objects, but was having some trouble, and needed to edit my notes.ini file to try and fix something.
The peculiar part was that in my program files directory, there was a notes.ini file – but with no real config in it, only a few lines – this files usually full of stuff! I also couldn’t see my ID file in the notes data directory when using explorer, but Notes could see it and access it fine!
After a bit of Googling, it turned out it was Vista redirecting application write access to the program files folder to “C:\Users\ %USERNAME% \AppData\Local\VirtualStore’. When the app reads from the program files folder it sees a merged version of the real program files folder and the users VirtualStore, so in essence forces apps to support multi users by the looks of it.
Posted in Apps, OS
From time to time you’ll come across the problem where a system’s machine account in active directory has either become out of sync (Usually due to multiple systems with the same name) or has just been deleted somehow! Telltale signs of this are errors about domain’s being unavailable, and trust relationships failing whenever the system tries to perform any authentication. In these situations you can usually log in as a local administrator, unjoin/rejoin the domain, then reboot and the problem is sorted.
However, this isn’t so easy if you aren’t in front of the system (which is often the case), although it is possible to do:
First you need to locate the IP address of the system (Names will be unreliable if you’ve got multiple systems with the same name!). The best way to find the IP is probably from looking at DHCP leases on your DHCP server. Once you have the IP address, run regedit.exe on another system, then from the file menu select ‘Connect remote registry’. In the following box, connect to \\<IPaddress>. You should then be able to log on to the system as the local admin user (SYSTEMNAME\Administrator), you should then be able to navigate to:
HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server
In this key, look for the ‘fDenyTSConnection’ value, and set this to 0. This should enable remote desktop if it isn’t already, you’ll need to reboot in order to enable this:
shutdown -m \\<IPAddress> -r
Once the system has rebooted, you should be able to remote desktop to it, log in as the local admin user, and rejoin as if you were in front of it. Although if it was a case of multiple systems with the same name, don’t forget to give it a unique name!
I should also point out that if it was a deleted computer account, you could always restore the object in AD, but that’s another story…
Posted in Networking, OS, Tips