Friday, June 8, 2012

"Could not find a part of the path" from MSBuild/CruiseControl.NET

This case turned out to be a no-brainer, but for my own (and others who may need it) later reference, here it is:
Scenario: I had set up a test environment for testing MSBuild targets run from CruiseControl.NET. The target I wanted to run was supposed to do simple file operations like copying and unzipping files to a specific disk letter, which in my test environment happened to be a subst to a folder on my local hard drive. Windows 7 64-bits with UAC (User Account Control) on was used, running CruiseControl.NET elevated to give it necessary privileges.
Problem: When running the MSBuild target itself, things worked like a dream. However, when running the target from CruiseControl.NET, it always grinded to a halt at the first attempt to copy/unzip data to my disk
Cause: This is the no-brainer: Since CruiseControl.NET ran with elevated privileges (i.e. started with "run as an administrator"), it did not see the substed drive I had set up from a non-elevated cmd window.
Solution: Simply start a cmd window elevated (run as administrator) and do the same subst from there, and voilla! - it works.

Sunday, March 4, 2012

SyncBack hang/freeze on Windows 7 - SMB version problem

Problem: SyncBack Free is a brilliant free tool for synchronizing two folders' contents fast and accurate. I had been using a Windows XP computer with two network cards standing as a bridge between two networks to sync folders between two computers residing on each side of the bridge. Old of age the XP computer were looking forward to its retirement as a young Win7 computer were set up to take over its place. The same SyncBack running the same SyncBack profile on the Win7 computer completely hung the SyncBack process within seconds after syncing was attempted. Only a reboot would kill the process - not even Task Manager managed to take it down.

Factors in the picture:
  • The two remote computers were running Win7  and Server 2008 R2.
  • Syncing between a local folder on the Win7 computer and one of the remote computers would work. Just not syncing between the two remote computers.
  • It made no difference whether Windows Shell (on the Copy/Delete tab) was used to sync or not.
  • Copying files between the remote computers from Windows explorer works just fine.
Problem reason: The reason proved to be SMB version. WinXP uses SMB 1.0, whileas Win7 uses SMB 2.0. For some reason, SyncBack does not manage to copy files between two remote computers as long as the computer is set up to use SMB 2.0.

Solution: Disable SMB v. 2.0, forcing the Win7 computer to revert to using SMB 1.0. This excellent article on Petri explains how - or here in short: From an administrative command line window run the following commands and then reboot to activate (Observe that "bowser" is actually correctly spelled - or rather, it is spelled the way that the computer understands):
sc config lanmanworkstation depend= bowser/mrxsmb10/nsi
sc config mrxsmb20 start= disabled
If you need to revert to SMB 2.0, use the following commands:
sc config lanmanworkstation depend= bowser/mrxsmb10/mrxsmb20/nsi
sc config mrxsmb20 start= auto 
I have not put any effort into researching whether security is an issue with these settings or whether other functionality is negatively affected, for me it gave me what I needed, so I am happy.

Friday, December 9, 2011

Administrator cannot change, delete or take ownership of file

Problem: It is well known that if a file is locked in Windows, an administrator can take control of the file by taking ownership of it, give himself permissions to write/delete it and then perform pretty much anything he needs to do with the file. Sometimes, however, you just receive an error message when you try to take ownership, even though you are an administrator, and even though the command prompt or Windows Explorer you are working from has been started by right-click - "Run as administrator"

Solution: Open Computer Management and open shared folders - open files. If the file in question is being held by someone that has opened the file over a fileshare, you first have to terminate their connection to the file before you can manipulate it. Of course, you should first make sure you are not disturbing any work they are doing on the file.