lunedì 28 novembre 2011

Problem with COSBI OpenSource Mark

If the workload does not work, it's usually a problem related to the fact that COSBI cannot write the .ini file.

The problem is associated to missing drivers. Install all the drivers needed, and all will work fine :)

sabato 26 novembre 2011

Repair SQL Server Database marked as Suspect or Corrupted

EXEC sp_resetstatus 'real_set_2'
ALTER DATABASE real_set_2 SET EMERGENCY
DBCC CheckDB ('real_set_2')
ALTER DATABASE real_set_2 SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ('real_set_2', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE real_set_2 SET MULTI_USER

mercoledì 23 novembre 2011

Windows XP Activation LOOP

To solve the loop, while we are trying to activate, press Windows Key + U, then in the window that pops up press the link to the Microsoft Website, and you will have a nice browser that will fulfill your desires :)

(source: http://www.thetomorrowtimes.com/2006/12/how-to-login-to-expired-windows.html)

mercoledì 2 novembre 2011

(Windows) NTP server for a private network


Need to have a NTP server for your private network?
You have machines that cannot access the Internet, but you need them to be time sync-ed?

I had this problem, and I solved it letting my "gateway" machine (i.e. Controller) become a NTP server.
First of all, activate the Windows Time service in Control Panel -> Administration Tools -> Services.
Then, modify the registry entry using regedit.exe in this way:

System Key: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters]
Value Name: LocalNTP
Data Type: REG_DWORD (DWORD Value)
Value Data: (0 = disabled, 1 = enabled)


Unfortuately, this solution doesn't work (at least for me).
On the other hand, this other solution I found here (http://www.techrepublic.com/blog/datacenter/configure-a-standalone-ntp-server-in-windows-server/3869) works fine ^_^

System Key: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NTPServer]
Value Name: Enable
Value Data: (0 = disabled, 1 = enabled)

Putting the data value to 1 enables the current machine to become a NTP server.
Then, in a command shell update the configuration of the Windows Time service:
> w32tm /config /update

and visualize the new configuration with:
> w32tm /query /configuration

The output should appear like the one in the image



Last step, update the new server machine using a NTP server on the Internet. If you don't do it, you can incurr in some synchronization problem on the clients, like this:
"Error (...) Peer's stratum is less than Host's stratum"
that practically means that the client doesn't trust the new NTP server, as it did not take time from anywhere.
Different thing is if you want to define your machine as a "standalone, trustable NTP server". In that case you need a Knowledge Base from Microsoft that alows to your machine to take the time only from the CMOS clock of your machine.

venerdì 28 ottobre 2011

VirtualBox + Powershell = genius (?) in the box

Today I'm facing another strange behavior of the command-line interface "vboxmanage.exe" for Oracle's VirtualBox.
Here is the Powershell code I'm executing on a remote machine to reboot a virtual machine:
$VM = "WindowsXP";
Invoke-Command -ScriptBlock {vboxmanage controlvm $args reset} -ArgumentList $VM ComputerName 10.3.2.127

Ok, I got an error that is:
VBoxManage.exe: error: Invalid machine state: PoweredOff
+ CategoryInfo : NotSpecified: (VBoxManage.exe:...ate: PoweredOff:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

VBoxManage.exe: error: Details: code VBOX_E_INVALID_VM_STATE (0x80bb0002), component Console, interface IConsole, callee IUnknown
Context: "Reset()" at line 124 of file VBoxManageControlVM.cpp

The weird thing is that on the machine that hosts the VM (10.3.2.127) the reset works fine.
I checked the execution state on both the host and the remote machine and... guess what... I discovered that the state was different: Powered Off on the remote machine, and running on the host.
host: State: running (since 2011-10-22T22:20:35.359000000)
remote: State: powered off (since 2011-10-18T14:39:32.000000000)
To be sure it was the same machine, I checked the UUID of the machine, and it is the same.
And the machine is accessible, too (it works!)
Another strange thing is the time since the VM results stopped on the remote machine, actually 4 days before, probably since the last try in "reset" the VM.

And here is the deal. When then I tried to start the machine remotely, I got this error:
Invoke-Command -ScriptBlock {vboxmanage startvm "WindowsXP" --type headless} -ArgumentList "WindowsXP" -ComputerName 10.3.2.127
Waiting for VM "WindowsXP" to power on...
VBoxManage.exe: error: Failed to open release log (could not open file 'C:\Documents and Settings\perfmon\VirtualBox VMs\WindowsXP\Logs\VBox.log' (fOpen=0x322), VERR_SHARING_VIOLATION)
+ CategoryInfo : NotSpecified: (VBoxManage.exe:...RING_VIOLATION):String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component Console, interface IConsole, callee

Then I recalled that the last time I started the VM directly from the host, and not from the remote machine.
Like this, the handler of the log file is still associated to the process which started the machine (on the host), and the powershell process, which tries to access the machine, cannot get the handler. This results in a false information about the state of the machine.

Thus, to solve the problem, I powered off the VM on the host, and I started it successfully on the remote machine:
Invoke-Command -ScriptBlock {vboxmanage startvm "WindowsXP" --type headless} -ArgumentList "WindowsXP" -ComputerName 10.3.2.127
Waiting for VM "WindowsXP" to power on...
VM "WindowsXP" has been successfully started.
and then I checked if the reset was working:
Invoke-Command -ScriptBlock {vboxmanage controlvm $args reset} -ArgumentList "WindowsXP" -ComputerName 10.3.2.127
and the machine state was:
State: running (since 2011-10-28T12:54:58.718000000)

Here we go!!! :)
Ivano 1, VirtualBox 0



giovedì 10 marzo 2011

Microsoft SQL (and other programs) crash due to mscorwks.dll

This kind of crash seems to be provoked in systems where several versions of .NET Framework are installed. About my case, I had .Net Framework 2.0 SP1 and .Net Compact Framework 2.0 SP2 (and also 3.0 and 3.5).

Just uninstalling .Net Compact Framework 2.0 SP2 solved the problem :)

In another case that I had, it was way harder, as I was not able to uninstall or reinstall any of the .Net frameworks. Luckily I found here the solution to my problem (http://blogs.msdn.com/b/astebner/archive/2009/02/18/9432938.aspx). It seems there is a tool coming with the framework that allows to you to repair any damaged file/registry key related to the framework.

Ciao!

mercoledì 9 marzo 2011

Erase the duplicates in a DB table (and "copy" tables!)

What if your table has got some duplicates (because you DO NOT define PRIMARY KEYS...)???

Well, we can select distinct rows from the table, and then create a new table with the resultset.
The syntax that we need is the following:

SELECT DISTINCT * INTO [new_table] FROM [old_table]
In addition, if the table already exist, we can use the INSERT INTO command:

INSERT INTO [new_table]
SELECT * FROM [old_table]

That's all!!! :)