Delete an undeletable file in Windows

I found a folder named with random sequence of digits and letters like 4b64f439c26281ab01b0a9ce. With contents cleary suggesting that this is some kind of garbage left by some installation process, most likey Windows Update or some core Windows driver update.

Many attempts to delete this folder, including this one failed, so I had to come with my own solution.

The fastest way

From mydigitallife.info comes the quickest solution with using command-line (run cmd.exe as an admin):

For files:

cd <folder>
takeown /f <filename>
icacls <filename> /grant administrators:F

Where:

  • <folder> is a full path to directory holding file, you want to delete or take ownership of
  • <filename> is questioned file name

Note, that original article has takeown /f <filename> /d y in second line, which was not working in my case, throwing some errors. Executing just takeown /f <filename> was enough.

For folders command sequence is very similar, only this time all actions will be performed recursively:

takeown /f <folder> /r /d y
icacls <folder> /grant administrators:F /t

Again, if takeown /f <folder> /r /d y fails, then try to use just takeown /f <folder> /r or just takeown /f <folder>. You can also remove the /r (from takeown) and /t (from icacls) switch to prevent the task been perform recursively.

For both solutions (for taking over files or folders) if you’re assigned to other user account or group than default administrators group, change administrators to the desired user name or group name accordingly.

This solution does not work in every situation, so follow to other solutions presented below.

The clickable way

This solution shows you, how you can gain permissions or take ownership of file or folder by clicking through endless number of windows and prompts. It is quite hard at the beginning, but can come handy at some point.

The thing, you need to know, is that Windows will do the best, to make you deleting such folder as hard as possible! As you can see on mentioned page, solution consists of five steps and nearly twenty points on check list. In my case, solution was quite different (given below), but still you have to reserve some time for this process, so don’t get your hands on this, if you have about a minute or so.

All right, let’s get to work.

I skip first part given in cited solution, as I assume, that you already have an administrator account enabled, you’re logged in and since you still can’t delete that damn folder, your frustration rises. Let’s get to second part. Remember, that you can start doing these things on root folder (i.e., the one you actually want to delete), but this will most likely fail, and you’ll have to start the entire job from changing properties and deleteing first of all subfolders in root folder.

Let’s start with changing owner of a folder:

  1. Right-click the folder, you want to delete. Go to the Security tab. Click the Advanced button at the bottom.
  2. In newly opened another window, go to the Owner tab and click the Edit button below the list.
  3. In third opened windows, check, if you have YOURACCOUNTNAME (YOURCOMPUTERNAMEYOURACCOUNTNAME) placed on list titled Change owner to. If not, reffer to Step 3.d in this article.
  4. Select YOURACCOUNTNAME (YOURCOMPUTERNAMEYOURACCOUNTNAME) on that list.
  5. Check Replace owner on subcontainers and objects checkbox to force Windows to propagate all changes.
  6. Click OK four times, to close all opened windows and to confirm, that you know, what you’re doing.

We’re talking about the account you’ve just logged in with (it, of course, have to have administrator rights or else, we have nothing to talk about).

Now, we have to deal with changing folder’s permissions:

  1. Again, right-click the folder, go to the Security tab and again click the Advanced button at the bottom.
  2. On the Permissions click the Change Permissions button.
  3. Uncheck Include inheritable permissions from this object's parent checkbox and click Add.
  4. Check Replace all child object permissions with inheritable permissions from this object.
  5. Select YOURACCOUNTNAME (YOURCOMPUTERNAMEYOURACCOUNTNAME) on list above and click Edit below it.
  6. Select second option (This folder, subfolders and files) on combobox below.
  7. Check first checkbox on the list below (Full control). This should mark all other checkboxes on that list.
  8. Make sure that the only checkbox below the list is not checked.
  9. Click OK four times, to close all open windows. After first click you’ll be prompted for confirmation. Click Yes.

After this mindless, stupid and very irritating process you should finally be able to delete this damn folder.

To conclude, let me tell you, that if above fail and you’ll still not be able to delete this folder, you have to options to consider:

  1. Repeat all above steps for all subfolders included in root folder (the one you want to delete).
  2. Repeat all above steps, but this time change owner and all permissions not for your own account, but for the entire group of administrators (i.e. Administrator (YOURCOMPUTERNAMEAdministrator)).

The visual way and some alternatives

mydigitallife.info have come with a fabulous guide on taking ownership of file or folder with many alternatives. Key article is above procedure, but this time heavily pictured. You’ll also find a command-line alternative mentioned in the beginning of this article as good as two others: for taking ownership by running a special prepared VBS script and by adding “Take Ownership” item to each file and folder context menu. Have fun.

Interactive mode command-line command for Yii1

For one of my projects I needed an interactive console command in Yii 1, i.e. the one that is gathering all information from user in an interactive mode (a serie of questions and answers displayed directly in the console), ignoring command-line arguments at all.

This is an example (or rather a bare foundation, as this actually is doing nothing) of such solution. It has some console text formatting methods (borders, text alignment) plus simple method for gathering user response.

Read More “Interactive mode command-line command for Yii1”

Render checkbox list with initially checked items in Yii2

This guide shows, how to (in Yii2) render checkbox list with correctly selected items (preselected during form render), using both HTML helper classes and active form approach.

This is an extended version of this Stack Overflow question and an answer following it, plus some additional information from me and from other sources.

Read More “Render checkbox list with initially checked items in Yii2”

Chained, AJAX-updated listboxes in Yii2

There’s a great answer at Stack Overflow that shows, how in Yii2 you can implement a form containing listbox and two input fields. Listbox contains data from one model and when user selects any option, remaining two input fields should be populated with relevant values from related model.

I wrote an extended version of this code. It populates two other listboxes instead of just input fields. And it uses a little bit less deprecated code! :>

Read More “Chained, AJAX-updated listboxes in Yii2”

Portable Storage vs Internal Storage in Android 6.0 Marshmallow

Differences: Motorola Support.

Card is encrypted and not accessible outside given device. Thus, for example, you can’t take it off, connect it to your computer and copy files that way, in case you couldn’t do this via USB cable (due to completely poor MTP protocol). For the same reason, if Android fail to recognise your SD card (happens awfully often under 6.0 Marshmallow) then you can’t access your files (i.e. download your pictures etc.) at all.

For security reasons (right!) card is encrypted, but for some strange reasons sometimes Android doesn’t work to well with its own encryption. This means that sometimes your files may become simply broken.

I had this problem with MP3 ringtones. From one day, without any particular reason, my phone started to emit some sound garbage as ringtones instead of my favorite songs. Quick analysis proven that poorly supported encryption plus even more poor MTP protocol plus broken connection between PC and Android resulted in files being broken.

Failures: Quora.

Git diagram for data transport commands

If you’re unfamiliar with data transport commands in Git or have troubles understanding the idea of four “buckets” (workspace, index, local repository and remote repository) or you’re generally a newbie to Git, then there’s a great answer at Stack Overflow, which basically is a diagram image taken from Oliver Steele’s blog and that actually explains everything! :>

Read More “Git diagram for data transport commands”

Changing Yii2 application’s configuration at runtime

You can’t use Yii::t() method inside Yii2 application’s configuration, right?

I mean… you can use it (application won’t fail), but you will always get string passed as method’s param in return, instead of actual translation, no matter, what language is currently set in your application.

This makes “How to translate application title (or any other configuration parameter)” a quite good question.

Read More “Changing Yii2 application’s configuration at runtime”

Media supported by Samsung 50HU6900 4K TV

Three months ago I have purchased my first 4K / UHD TV — Samsung 50HU6900 — and after some time I tried to used the built-in media player to play some of my files. At the very end it turned out that — as in all Samsung devices — this is a piece of crap, full of some strange limitations. Finally, I have reverted back to my old, good standalone FHD player and I’m using Samsung one only for UHD / 4K files.

But, for all of you, that aren’t so reluctant, here is a list of media supported by this TV (and probably many more Samsung TVs) and all the limitations, you need to fulfill in order to have your media played.

Read More “Media supported by Samsung 50HU6900 4K TV”

Create a loop in a stored procedure to insert many rows with random data

A solution based on this Stack Overflow answer to insert many random data rows to given table in SQL:

TRUNCATE TABLE `devices`;

DROP PROCEDURE IF EXISTS InsertRand;

DELIMITER $$
CREATE PROCEDURE InsertRand(IN NumRows INT)
    BEGIN
        DECLARE i INT;
        SET i = 1;
        START TRANSACTION;
        WHILE i <= NumRows DO
            SET @dn = CONV(FLOOR(RAND() * 99999999999999), 20, 36);
            INSERT INTO `devs` VALUES (NULL, FLOOR((RAND() * 3)), CONCAT('Dev ', @dn));
            SET i = i + 1;
        END WHILE;
        COMMIT;
    END$$
DELIMITER;

To execute this little piece just call:

CALL InsertRand(77);

That’s all folks! :>

Migration that requires user confirmation to continue

Since there’s a pure Linux underlying PHP, you can use STDIN (actually: php://stdin) and read it with fopen when your PHP script is run in console to stop execution of your script and read a button user pressed.

Since Yii migrations are run in console, you can use this mechanism to ask user whether she or he want to continue with your database migration.

Quite handy in some scenarios (like: destroying entire database), don’t you think?

Read More “Migration that requires user confirmation to continue”

Converting database structure or .sql file into Yii migration

Yii Framework 1.x migration system is very powerful and gives you much more power and control over database update process. But it becomes a horrible nightmare, if you have to deal with .sql files and convert them into Yii migration files manually.

This article should help you in that strike or at least ease your work.

If you have any doubts, why the hell migrations are better than using plan .sql files then this blog post should provide you with at least some reasons.

Read More “Converting database structure or .sql file into Yii migration”

From Drupal-based blog to Yii-based application

If you are in need to migrate Drupal’s content data (articles, pages, events, etc.) to your own CMS or database structure then this article may be helpful for you.

Note however, that I have little to none knowledge of Drupal and that my MySQL experience is very limited. Therefore, information provided in this article may be useful, but on the other hand, I can write something wrong (even up to a complete bullshit) or mess things around.

Use this text with a caution and at your own risk. You have been warned. No money back guaranteed! :>

Read More “From Drupal-based blog to Yii-based application”

Importing large datasets to MySQL using command-line

Command-line MySQL client is way faster and more stable for importing large datasets into MySQL database. For all those Linux geeks, this is of course obvious. But, for use, lame Windowsers, using phpMyAdmin was nearly always a better choice, and this such articles like this still should be written! :>

In my case, it was 152 tables, nearly 120k records and 30 MB of uncompressed .sql file.

Read More “Importing large datasets to MySQL using command-line”

Changing default PowerPoint presentation

Changing default document for Word (i.e., the one, that is opened each time you start Word) is an easy task. You just have to open %APPDATA%\Microsoft\Templates folder and save any document as Word Template under Normal.dot file name in this location. Changing default PowerPoint isn’t that easy, because file names and file paths are different. I keep forgetting about this, so I wrote this article as my personal memo.

Read More “Changing default PowerPoint presentation”

Force macro-enabled documents to not display warning after opening

If you work with macro-enabled documents in Microsoft Office and you run on default settings, each such file will be always opened with macros disabled and you’ll have to click Enable macros each time to enable it. If documents are your own, you trust, that they contain no malicious code and they’re all stored in a secure location (i.e. not in some temporal or shared folder), you can change each Office program settings to have these files always opened with macros enabled.

Read More “Force macro-enabled documents to not display warning after opening”

Implementing own slideshow functionality to Colorbox

I have set slideshow:true in Colorbox‘s configuration and Start slideshow link didn’t appear.

I was pretty sure, that this is due to some stupid bug made by me, but because I was on steroids that day, instead of investigating on what is wrong, I decided to write my own implementation of slideshow func.

Code isn’t pretty, but it can be useful for beginners in determining, how events and other stuff around Colorbox works. This example can also be useful for implementing slideshow functionality to other, non-Colorbox, photo gallery libs, that do not have this functionality implemented in core.

Read More “Implementing own slideshow functionality to Colorbox”

Combine pure string and jQuery object. A word about outerHTML property

You can’t simply combine pure string and jQuery object using Javascript concatenation operator (+). You cannot easily mix strings and DOM elements. So, something so trivial like surrounding link with [ and ] brackets becomes not so trivial. At least to beginners. This article should help.

Read More “Combine pure string and jQuery object. A word about outerHTML property”