Monday, April 8, 2013

How to solve Folders Showing as Shortcuts, Hidden in USB/Memory-Card/HDD

By connecting flash drives to the affected computer, often it shows flash drive containing just some folder's shortcuts. Sometimes it shows nothing though drive's properties show it has files in it. Even we get some inaccessible folder or file. This type of problem may also seen in our local drives (HDD partitions). Even paid anti-virus is unable to resolve those folders, they just scan and detect The AUTORUN worm which one will execute all programs. Then our important files remain hidden.

hidden folders shortcuts
Hidden folders and Shortcuts by the Autorun Worm


Here we will see how can we solve this problem by using command line and batch file. Though the batch file is nothing but the executable file contains command lines. So solving the hidden and shortcut problem of USB or drives, we must have the administrator privilege as we will execute something.

Using Command line:

To solve/fix the folder's hidden or system file, the easiest way is to run a command line. You can apply this command to USB and local drive as well, need to change the drive_letter.

Go to Run, type cmd and hit enter. In command prompt just type:

attrib -h -s -r -a /s /d drive_letter:\*.* 

And hit enter. Be sure you've typed the drive letter (e.g. j:,h: or D:) instead of "drive_letter" in the command line. My USB drive letter is J: and my command should looks like:
Command to change files attributs
Command for unhide system-hidden files on a drive

All files and folders will be normal and you should be able to delete the shortcuts, created by the virus.
Command line details: Here atrib=attribute, "-"=remove attribute/permits, h=hidden s=system, r=read-only, a=archive, /s=sub directory, /d=directory, drive_letter=the letter of the drive shown in windows explorer (e.g. j:,h: or D:) and *.* is called the wild card for all files.
If you don't like to be a "command Ninja" then see below.

USB, MicroSD, MiniSD or other Mmory Cards issue:

     1. Connect your USB or memory card to the PC or laptop.

     2. Copy these lines and paste it into a "new text file" 

@echo off
attrib -h -s -r -a /s /d drive_letter:\*.*

3. In the 3rd line give the drive letter name (Example: J or K or L etc.) instead of "drive_name"

4. Save the text file as any_name.bat

5. Double click on the any_name.bat file and it will run in the command prompt and see the hidden files/folders come back.

6. Delete the shortcuts and unnecessary files and folders from USB drive.

Local drive issue:

1. Copy these lines and paste it into a "new text file"

@echo off 
attrib -h -s -r -a /s /d D:\*.*
attrib -h -s -r -a /s /d E:\*.*
attrib -h -s -r -a /s /d F:\*.*
attrib -h -s -r -a /s /d G:\*.*
attrib -h -s -r -a /s /d H:\*.*
attrib -h -s -r -a /s /d I:\*.*
attrib -h -s -r -a /s /d J:\*.*
@echo complete.

2. Save the text file as a bat file (example: any_name.bat)

3. Run this bat file by double-clicking on it.

Thus you can solve this kind of problems with a *.bat file. You can save the *.bat file for solving this hidden problem.

Important: These tutorials are applied for Windows 7/Vista/xp. You must have the administrative privilege to run the command or execute the .bat file. Put the " : " after the j, k, or D (drive letters). These commands are not case sensitive.

Monday, March 4, 2013

Preserving Ordering With WHERE in() Clause in MySQL



Today I ran into the code that pulls from database list of elements with
1
SELECT * FROM table WHERE id IN(2,5,3,16,22,56,48)
where order of ids is important to be preserved after results found. When using SELECT this way you will get the results for every id but ordered by id in ascending order. I was looking around and found neat solution to make MySQL work for you to preserve the order of returned results. With ORDER BY FIELD clause like here
1
2
SELECT * FROM table WHERE id IN (1,5,2,13,4)
ORDER BY FIELD(id, 1,5,2,13,4)
you can keep the initial ordering. What is the catch. This way id field can not be used as indexed. Therefore,
1
2
EXPLAIN SELECT * FROM table
WHERE id IN (1,5,2,13,4) ORDER BY FIELD(id, 1,5,2,13,4)
would give you the information that it is using filesort for results ordering which is not so nice. In general, when you have ids as the array with the ordering you need, it probably needs less resources to reorganize them in memory instead of letting MySQL doing it with filesort.

Tuesday, February 12, 2013

Debugging Silverlight application problem


Depending on my experience in Silverlight following these steps keep your project debug-gable.
Condition 1>
Firstly we need to be ensure that in Web Project's properties there is a Web section, as you see below Silverlight checkbox must be checked.
enter image description here
Condition 2> Follow In Menu Debug => Attach Debugger>
Visual Studio sometimes can't attach debugging platform you need to lead the way :) . By this way you may debug other platforms,(also you may debug your product platform but pdb files must be sync and don't forget you may suspend your product platform using this).
enter image description here
Condition 3> Your default web browser may be Firefox,Chrome or other than IE.By Visual Studio default try to attach to IE. But when you run VS calls default browser,so you need to have a manual attachment in Condition 2 or set your default browser by right clicking on default page > Browse with .
enter image description here
Condition 4> There is xap file generally located in web project\ClientBin directory. Sometimes after build operations this file can't be replaced and your ProjectDll and your Project PDB files not be sync. This cause wrong line match while debugging or can't find a debugging file attached caution. I strongly suggest delete all generated files in Bus project and delete Clientbin\ProjectName.xap file. After rebuild all it must be ok!
enter image description here
Hope helps.