Tuesday, May 11, 2021

To kill a stubborn

In MS-SQL, on an attempt to drop a DB getting an 'in use' error, even after it switched to the singly user mode by executing

USE master
GO
ALTER DATABASE [DB]
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE [DB]
SET READ_ONLY;
GO


As suggested in an answer here, there is a way to find who is actually using the DB:

 

  select  d.name , convert (smallint, req_spid) As spid
      from master.dbo.syslockinfo l, 
           master.dbo.spt_values v,
           master.dbo.spt_values x, 
           master.dbo.spt_values u, 
           master.dbo.sysdatabases d
      where   l.rsc_type = v.number 
      and v.type = 'LR' 
      and l.req_status = x.number 
      and x.type = 'LS' 
      and l.req_mode + 1 = u.number
      and u.type = 'L' 
      and l.rsc_dbid = d.dbid 
      and rsc_dbid = (select top 1 dbid from 
                      master..sysdatabases 
                      where name like 'DB')


Tuesday, April 20, 2021

Ghost Files

In  Windows a space is not allowed in the end of a file name. When such a file is somehow created, it cannot be removed by regular means. As a workaround, try to specify the file location with the following notation:

"\\?\D:\path\filename "

 

Thursday, June 28, 2018

Fighting iOS paranoia

Newer iOS version do not trust custom issued certificates by default. To make a certificate trusted, do the following:
  1. Send the CA certificate to some other email available from the device as an attachment.
  2. Once received, tap on it and install it to a "profile"
  3. Go to Settings->General->About->Certificate Trust Settings
  4. You should see your CA certificate profile there. Make it trusted.

Monday, April 18, 2016

Youtube error

YouTube's HTML5 player failed to play on Mozilla SeaMonkey browser.
To make it work do the following:
  1. Go to the about:config page
  2. Set the value of media.fragmented-mp4.enabled to false
UPD: that settings prevents some site to show video gifs.
Looks like this setting works better:
media.mediasource.webm.enabled: true

Monday, January 18, 2016

Bitlocker

A new Surface laptop came with the bitlocker is not activated, but the hard drive was yet encrypted. The owner asked to turn off the encryption completely.
The UI of Windows 10 does not provide such an ability, but that could be achieved using the command line utility:
 manage-bde -off C: 

Read more how bitlocker works here.

Wednesday, October 28, 2015

Poor thing.

Blackberry PRIV for $700 ??? They will never make it.

Saturday, July 18, 2015

To remove a wrong driver in windows

Was unable to connect a neighbor's Nook Color as a mass storage drive to a windows computer. Turned out the ClockworkMod universal ADB drivers installed earlier have a priority and won't let the usbstor.sys (the mass storage) to be selected a the primary device driver. Uninstalling the driver for the device in the Device Manager did not help, it appeared again after the device was unpluged and then plugged again.
Knowing the vendor and product IDs (for the Nook Color they are VID_2080&PID_0002), I found the ClockWork's oem##.inf file in the %SystemRoot%\inf folder.
Where ## is a number of the .inf file where the device VID and PID were mentioned.
Tried to delete that oem##.inf and then reboot the PC, did not help.
But what did help, is Window's pnputil utility.
Execute the following command as administrator and then even no need to reboot:
pnputil -d oem##.inf

Also, there is an useful utility to maintain the currently and previously connected USB devices.

Saturday, June 20, 2015

Cisco VPN client issue

Windows 8.1 with Bing, came with a netbook computer.
Need to make work the Cisco VPN client which gives the following error on a connect attempt:

Secure VPN Connection terminated locally by the Client, Reason: 440 Driver Failure

Tried this solution to install Citrix DNE. Did not help.

The event viewer shows that the driver signature can not be verified.
Desperatly did the following to make it work:
  1. Turned off the BitLocker. Well, why I need a secured notebook which I can not use?
  2. Disabled UEFI's Secured Boot. 
  3. Executed the following commands:
    bcdedit -set loadoptions DISABLE_INTEGRITY_CHECKS
    bcdedit -set TESTSIGNING ON
  4. Reinstalled the Cisco VPN client.
Works now!

Friday, March 27, 2015

Windows backup command line

Windows 8.1 does not have an GUI tool to schedule a regular system image backup.
But there is a command line which could be placed to the task scheduler:

wbAdmin Start Backup -backupTarget:E: -include:C:,D: -allCritical -quiet

Get the description of the wbAdmin command options by typing:

wbAdmin Start Backup /?

To restore the backup, first boot to the recovery partition. To do so on a healthy system (if the system is corrupted it should boot the recovery automatically) hold the Shift key when you click the "Reboot" button.

Thursday, February 5, 2015

Cure for IE's paranoia

After the update KB3025390 was installed for IE11, it's stopped to allow access to its internal objects from outside. As it was described in this article, this behaviour could be cured by the following registry changes:
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_DISABLE_INTERNAL_SECURITY_MANAGER]
"iexplore.exe"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_DISABLE_INTERNAL_SECURITY_MANAGER]
"iexplore.exe"=dword:00000001


Update: MS has released an update KB 3021952. To be installed to solve the issue instead of hacking the registry.


See also: http://www.inflectra.com/Support/KnowledgeBase/KB105.aspx

Saturday, October 25, 2014

PC hunter

Sometimes when you try to modify a registry key you are getting "access denied" and even changing the ownership does not help. In this case try a free utility called "PC Hunter". It lets you to delete a problem registry node and then you could just created it back with default permissions.
The link to download: http://www.xuetr.com/download/PCHunter_free.zip
Original article the utility was mentioned:
https://www.raymond.cc/blog/full-control-permission-to-delete-or-edit-restricted-windows-registry/2/

Monday, September 8, 2014

hyperswitch

On windows, you should choose, either you use the Hyper-V or a third party virtual machines (such as android emulator with virtualization support provided by Intel x86 Emulator Accelerator (HAZM)).

In the second case the system hypervisor should be turned off:

bcdedit /set hypervisorlaunchtype off

 To turn it back on execute:

bcdedit /set hypervisorlaunchtype auto start

Reboot.

Tuesday, September 2, 2014

Skype little hack

As we all know, all of the sudden Micro$oft stopped to support old version of Skype. But new Linux version of skype client is buggy and glitchy.
I was able to make the skype work. Do the following. Open the file /usr/bin/skype in a hex editor (I used the Midnight Commander viewer) and search for the version number. In my case it was the string 4.2.0.11
Replace the string with 4.3.0.37 and save.
Run skype now and enter the credentials. Should connect just fine.

Monday, June 23, 2014

runas.vbs

Very simple script to run a command line application with elevated privileges: 

if WScript.Arguments.Length > 0 Then
    Set objShell = CreateObject("Shell.Application")
    dim a : a = ""
    for i=1 to WScript.Arguments.Length-1
        a = a & WScript.Arguments(i) & " "
    next
    objShell.ShellExecute WScript.Arguments(0), a, "", "runas"
end if

Monday, April 14, 2014

Sick FTP service

On Windows 2008R2 server, a freshly installed FTP service does not accept an external connection attempts, even if the FTP firewall rule is enabled.
Could be cured by issuing the following command:
netsh advfirewall set global StatefulFTP disable
Then restart of the ftpsvc service.

Tuesday, January 14, 2014

SQLXML Bulk import


Import a single table

Get the XSD schema file and add the following markups to it:
  1. Mark the parent  elements which do not have a corresponded database table as sql:is-constant="1"
  2. Mark the iterated element which each instance should go to a record as sql:relation="DB_table_name"
  3. Mark the elements which do not have a corresponded database field as sql:mapped="false"
  4. Assign the field name to the elements which database field name is different with sql:field="DB_field_name"
  5. Make sure the field length are roomy enough to fit all the data
  6. Automatic convertion of date fields does not work properly, so such DB field should be type of string.

Setup a relationship between tables

  1. Add the sql:relationship element to xsd:annotation/xsd:appinfo
  2. Add attributes which declare the name="Relationship_annotation_name" (random identifier string) and the related DB tables and PK-FK fields as described here. 
  3. To the same element where you declared the child DB table name with sql:relation="DB_table_name" add the attribute which references to the declared relationship: sql:relationship="Relationship_annotation_name"
See more examples here.

Execute the prepared bulk import setup

Download and install the SQLXMLBulkload object and execute a VbScript like the following:

set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkload.4.0")
objBL.ConnectionString = "Connection String to the database"
objBL.ErrorLogFile = "error.log"
objBL.CheckConstraints=True
objBL.KeepNulls=True
objBL.Execute "annotated_schema.xsd", "input_data.xml"


If the object returns an error, check this site, may be it will give you a clue. The log file sometimes contains a bit more information than in the thrown error description.

Object properties to configure

If the tables already exist the .SchemaGen property of the SQLXMLBulkload object should remain FALSE.
If it is set to TRUE, the tables will be created automatically.
String XSD type is declared as [nvarchar](1000).

.KeepIdentity could be useful when a normalized table structure is created, in other words when an attempt to insert a reference record fails when the record already was created (with the primary key). If the property is set to True the records are inserted one by one which is a lot slower than the default bulk inserting. But the reference records duplicates will not be created.

.KeepNulls is useful to left the fields NULL when there is no actual value in the XML.


Here's the list of all properties of the SQLXMLBulkload object.


Sunday, November 24, 2013

Bring Eclipse back on track

All of the sudden, Eclipse stopped working. It started doing something, taking forever for some weird initialization processes like "initializing java tooling" and the similar.

A tip from this site actually  helped to solve the issue:
Kill the stale Eclipse, delete the folder
.metadata/.plugins/org.eclipse.core.resources/.projects
and start the Eclipse again. The folder will be created on the next start.




Don't forget also to delete .metadata/.lock each time Eclipse crashes or being killed.
 

Saturday, August 24, 2013

Remotely connect to the windows 2008 console.

Windows server won't let you to connect to the physical console session remotely.
Bot that's still possible.

Connect to a new session, then execute the following command:

tscon.exe 1

replace "1" with the console session if it's differ. To know it, open the task manager's Users tab and look for the console session id number.

Wednesday, April 24, 2013

To change the network profile

If you wired two PC together using a crossover cable or a hub without an outbound connection, windows makes the network connection type (profile) "Public" and all the public firewall rules will be applied. It's possible to make it "Private" using the script as described in this blog.


Monday, April 8, 2013

MS SQL 2008 rake

If you want to modify a table property through the UI which requires a table recreation, then you need to change the following options in Management Studio:
Tools ->Options-> Designers -> Table and Database Designers -> uncheck the option "Prevent saving changes that require table re-creation"

from here