Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Tuesday, September 17, 2019

ADB.exe crashing 0xc000005 on winusb.dll

An issue I've had on my work laptop with adb.exe crashing with 0xc000005 for last couple of months, I finally managed to fix it today after several attempts in various ways.


Monitoring the process with Process Monitor would reveal that is crashes after working with WINUSB.dll (ignore the highlight in blue, that was on the first attempt checking, the file should not be there)


SFC scan shows no problems with the file.
sfc /SCANFILE=C:\Windows\SysWOW64\winusb.dll

Trying the same Android SDK installation in the Windows Sandbox VM shows it working correctly, so it must be something on my physical system. The winusb.dll files on both systems show the same version, although on copying to the phyical system in te mporary location and comparing with FC /B clearly shows differences.

Now with the new version of SysWow64\winusb.dll at hand, I would try to replace the original on the physical system without success as it is owned and protected by Trusted Installer service.

Searching the web for a tool that would allow to run a process (e.g. cmd.exe or explorer.exe) as TrustedInstaller user found ExecTI from WinAero.


This would allow me to rename the old file and copy the new one in from the clean Sandbox image.

cd /D %WINDIR%\SysWow64
rename winusb.dll winusb.dll.BROKEN
copy WHERE_YOU_COPIED_IT_FROM_SANDBOX\winusb.dll winusb.dll

Running ADB again would show it working succesfully now!

adb --version
Android Debug Bridge version 1.0.41
Version 29.0.4-5871666
Installed as D:\Program Files\Android\android-sdk\platform-tools\adb.exe

Friday, May 18, 2018

Mounting OSFMount RAM drive on boot

Updated: 16 Apr 2020

I have used a number of RAM drives over time and more in the recent years with the increase in amount of RAM available to store user temporary files (autoclean on power down) and even projects build output directories (try and reduce some build times).

PassMark OSFMount might still be missing some features compared to other available RAM drive software out there, but it is free and it has received a number of improvements lately.

Install software

Download OSFMount (v3.0.1005, 29 Jul 2019 at the time of writing) and follow the installation instructions, nothing special there.

Create automount script

The script will mount the drive if the letter is available and it uses its internal format command which can only format FAT32 at the moment. Adjust the settings to fit depending on your needs and available free RAM (check with Task Manager > Performance > Memory). Save in a system (e.g. "%WINDIR%\Create RAM Drive + TEMP directory.cmd") or user location.
@ECHO OFF
SET RAMDISK_DRIVE=R:
SET RAMDISK_SIZE=1G
SET RAMDISK_LABEL=RAM Disk
IF NOT EXIST "%RAMDISK_DRIVE%" (
  "%PROGRAMFILES%\OSFMount\OSFMount.com" -a -t vm -s %RAMDISK_SIZE% -o format:fat32:"%RAMDISK_LABEL%" -m "%RAMDISK_DRIVE%
  MKDIR "%RAMDISK_DRIVE%\TEMP"
)
If you test run it in an elevated Command Prompt it should output like below:
"%WINDIR%\Create RAM Drive + TEMP directory.cmd"
Creating device...
Created device 0: R: -> VM image
Formatting drive with volume label RAM Disk
Notifying applications...
Done.


Task Scheduler

Create a scheduled task in Task Scheduler (taskschd.msc),  the important parts are to run At system startup and to Run whether user is logged on or not.




Finishing notes

Reboot and confirm RAM drive is there on startup.



IMPORTANT NOTE:

If you intend to change your user TEMP and TMP environment variables to point to R:\TEMP with a small RAM drive you can run into all sorts of weird issues when installing large applications or with anything that takes large amounts of temporary disk space for operating like Android sdkmanager update or anything like that.

If you still want to go this way cause you think you know what you're doing, any time something weird happens like that happens I would remember to change your TEMP and TMP environment variables back to default %USERPROFILE%\AppData\Local\Temp, logoff and try the operation again.

I have never considered changing system's TEMP or TMP environment variables, just the user ones.

Friday, May 24, 2013

Android Emulator performance - Windows 8 vs Ubuntu 13.04

I mentioned earlier I've been trying Ubuntu for Android development, and today I'll try to capture the difference in performance of the Android emulator on the two platforms. I haven't seen much difference in terms of Eclipse performance, but when it comes down to the Emulator it is quite obvious.

I'm not quite sure what makes the difference so large, might be the OS or maybe the QEMU software implementation on each OS. I chose to test with Android 4.2.2 AVD images just to push it - older versions like Android 2.1 or 2.3 seem to work better.

Also I'm running the tests on my home Dell laptop which is a few years old, making the difference even more obvious. I find Windows 8 on this machine faster than Windows 7 and generally a pleasant experience while probably on par with Ubuntu 13.04 in terms of performance.

While I find Windows more familiar and easier to use, because of the poor Android emulator experience on Windows I find using Ubuntu a less annoying experience for this particular task.

Environment


Machine

  • Dell Vostro 1520
  • 15.4” Widescreen WXGA+ CCLF, anti-glare (1440x900);
  • Intel Core 2 Duo P8600 (2.4 GHz, 1066 Mhz, 3 MB cache);
  • Intel® 45 Express chipset
  • Intel Integrated GMA 4500MHD;
  • 4 GB RAM, 800 MHz DDR2 Dual Channel;
  • 320 GB Seagate ST9320423ASG 7200 rpm, NCQ enabled;

    Windows 8

    • Windows 8 (x64)
      Version: 6.2.9200
    • android-sdk\tools\emulator-x86.exe
      Version: n/a
      Build Time: Tue May 14 02:49:56 2013
    • Intel HAXM 1.0.6 
    • Intel 4 Series Express display driver
      WDDM 1.1, 8.15.10.2702

    Ubuntu 13.04

    • Ubuntu 13.04 (x64)
      Linux VOSTRO 3.8.0-21-generic #32-Ubuntu SMP Tue May 14 22:16:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
    • android-sdk/tools/emulator64-x86
      Android emulator version 22.0 (build_id OPENMASTER-675183)

    Eclipse / Android SDK

    • Eclipse 4.3 M7 x64, Kepler
      • 20130509-1105 (x64) - Windows
      • 20130225-0426 (x64) - Ubuntu
    • Oracle / Sun JDK 1.7.0_21 (x64)
    • Android SDK Tools 22
    • Android SDK Platform Tools 17
    • Android 4.2.2 (API 17) - Intel x86 Atom System Image rev. 1

    Android Virtual Devices


    Phone

    • 3.2" QVGA (320 x 480: mdpi)
    • Android 4.2.2 - API Level 17
    • Intel Atom (x86)
    • RAM: 512 MB
    • VM Heap: 16 MB
    • Internal Storage: 200 MB
    • SD Card: 200 MB
    • Use Host GPU

    Nexus 7

    • Nexus 7 (7.27", 800 x 1280: tvdpi)
    • Android 4.2.2 - API Level 17
    • Intel Atom (x86)
    • RAM: 512 MB
    • VM Heap: 32 MB
    • Internal Storage: 200 MB
    • SD Card: 200 MB
    • Use Host GPU

    Windows 8


    Performance on the Phone AVD is acceptable although slightly laggy, using Intel HAXM 1.0.6 and "Use Host GPU" option. My GPU chip / driver don't seem to support OpenGL 2.0 (1.1 only?), showing in the startup messages.
    Starting emulator for AVD 'Phone_4.2'
    Failed to create Context 0x3005
    could not get wglGetExtensionsStringARB
    emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
    could not get wglGetExtensionsStringARB
    could not get wglGetExtensionsStringARB
    could not get wglGetExtensionsStringARB
    could not get wglGetExtensionsStringARB
    could not get wglGetExtensionsStringARB
    could not get wglGetExtensionsStringARB
    could not get wglGetExtensionsStringARB
    emulator: device fd:688
    HAX is working and emulator runs in fast virt mode
    AnTuTu Benchmark v3.3 scores:
    • Total: 13,837
    • CPU: 7,503
    • GPU: 141
    • RAM: 5,643
    • I/O: 550

    For Nexus 7 AVD, I had to drop down the RAM to 512 MB to get HAXM working with it, maybe because I configured HAXM earlier to only use 512 MB, trying to avoid the system running out of memory (only 4 GB of RAM). The experience is laggy (1-2 seconds wait between activities), barely usable - disabling animations helps a bit.
    Starting emulator for AVD 'Nexus_7'
    Failed to create Context 0x3005
    could not get wglGetExtensionsStringARB
    emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
    could not get wglGetExtensionsStringARB
    could not get wglGetExtensionsStringARB
    could not get wglGetExtensionsStringARB
    could not get wglGetExtensionsStringARB
    could not get wglGetExtensionsStringARB
    could not get wglGetExtensionsStringARB
    could not get wglGetExtensionsStringARB
    emulator: device fd:692
    HAX is working and emulator runs in fast virt mode
    emulator: emulator window was out of view and was recentered
    AnTuTu Benchmark v3.3 scores:
    • Total: 11,572
    • CPU: 6,282
    • GPU: 42
    • RAM: 4,713
    • I/O: 535

    Ubuntu 13.04


    Emulators start in seconds (15-30) to desktop, compared to minutes (1-3) in Windows!

    Phone 4.2 AVD is quite snappy, and haven't done anything special for it like install KVM. No additional messages at startup. AnTuTu shows same OpenGL 1.1 on screen during testing, but the FPS is much higher (~60 fps)!

    AnTuTu Benchmark v3.3 scores:
    • Total: 15,440
    • CPU: 7,728
    • GPU: 1,234
    • RAM: 5,918
    • I/O: 560

    Nexus 7 AVD starts quickly and it's very snappy! Navigation through activities and scrolling is very responsive, a huge difference from Windows. Some error messages at image startup though:
    Starting emulator for AVD 'Nexus_7'
    Failed to load libGL.so
    error libGL.so: cannot open shared object file: No such file or directory
    Failed to load libGL.so
    error libGL.so: cannot open shared object file: No such file or directory
    emulator: emulator window was out of view and was recentered
    Reading this thread I created the link below to fix the error message - didn't see any change in the scores though.
    # sudo apt-get install libgl1-mesa-dev
    # sudo ln -sv /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/libGL.so
    ‘/usr/lib/libGL.so’ -> ‘/usr/lib/x86_64-linux-gnu/libGL.so’
    
    AnTuTu Benchmark v3.3 scores:
    • Total: 14,104
    • CPU: 7,365
    • GPU: 538
    • RAM: 5,662
    • I/O: 560

    Monday, February 25, 2013

    How to find a better wi-fi channel (again)

    My Devolo dLAN power-line adapters stopped working recently (just not being able to find each other) and I had to go back to my old wi-fi WDS setup to connect to Xbox Live - which was working fine most of the time, but occasionally dropping connection, most annoying when in the middle of a game.

    Now it's been a while since I last checked the wi-fi channels around as everything was fine for my laptop(s) and mobile phone. Will use MetaGeek inSSIDer 3 to check the signal strength - they've got a pretty good video overview for version 2.

    First screenshot, from the living room (away from the router) - on channel 6 the signal strength is wavy, with a good few networks around, I guess that explains my connection dropping. (side note: I turned off my other WDS router, just to simplify things and make channel switching easier).


    Trying a few channels I eventually got to channel 10 where the signal strength seems to be stable.


    You're probably wondering why din't you go for channels 1-3, there's no network there?! Well, I did - 10 wasn't my first choice, I tried a few, including 1, which proved that although the signal strength was very good I was not able to connect to my network at all!!! Windows going in "limited connection" mode.


    That was surprising, but coming closer to the router shows some networks I could not see from further away! So I guess it's either that or some other non wi-fi device causing the interference on that frequency, but it was completely unusable for me although the signal strength would have indicated it as a very good choice.


    Some final notes:

    • try a few channels and see how they fare, rather than just go for the usual recommended (non-overlapping).
      Speedtest.net is a good test, although the actual external Internet speed may fluctuate giving you inconsistent results, run it a few times per channel. Pinging your router might give you a better (local) picture or transfer a larger file between two computers.
    • check things again when you see a drop in performance or connection. Other people turn their routers on / off at different times.
    • check that all your devices can still connect.
      Although your router might offer channels above 11, some of your devices will not be able to connect to them (e.g. Android phones) as some frequencies are not allowed in North America and the device OS / driver will not allow it even if you are living in Europe, see 802.11 Channels and international compatibility.

    Tuesday, January 22, 2013

    How to NTFS compress Windows WinSxS folder

    You may have an older computer, a smaller SSD or a VM with little space left on the system partition, and you need a couple of GBs of disk quickly. You did all the clean-up you could with Windows Disk Clean-Up or CCleaner, then you checked what's using most your disk with WinDirStat or TreeSize Personal, and now you may be thinking that WinSxS folder is quite large... I don't know about cleaning it up, but you can definitely try compressing it at filesystem level.

    Before we go on, now it might be a good time to do that system partition backup you've been putting off for so long, just in case.

    1. Start a Command Prompt (cmd.exe) as Administrator, in which to run the commands below.

    2. Stop and disable Windows Installer and Windows Module Installer services (see sc):
    sc stop msiserver
    sc stop TrustedInstaller
    
    sc config msiserver start= disabled
    sc config TrustedInstaller start= disabled

    3. Backup ACLs for WinSxS folder (see icacls), so we can restore later:
    icacls "%WINDIR%\WinSxS" /save "%WINDIR%\WinSxS.acl" /t
    
    [...]
    Successfully processed 44231 files; Failed processing 0 files
    

    4. Take ownership of WinSxS and subfolders (see takeown):
    takeown /f "%WINDIR%\WinSxS" /r
    
    SUCCESS: The file (or folder): "C:\Windows\WinSxS" now owned by user "COMPUTER\User".
    [...]
    SUCCESS: The file (or folder): "C:\Windows\WinSxS\x86_xnacc.inf_31bf3856ad364e35_6.1.7600.16385_none_b381dfe1d4da7da9\xnacc.sys" now owned by user "COMPUTER\User".
    

    5. Grant full rights on WinSxS to your user:
    icacls "%WINDIR%\WinSxS" /grant "%USERDOMAIN%\%USERNAME%":(F) /t
    
    processed file: C:\Windows\WinSxS
    [...]
    Successfully processed 44231 files; Failed processing 0 files
    

    6. Compress WinSxS files and sub-folders (see compact).

    Some files might still be in use by say Explorer, you can see that by running the command without /i parameter so that is stops on first file in use and then use CTRL+F in Process Explorer to search for the file name. It should compress most of the files anyways, so we'll ignore those.
    compact /c /s:"%WINDIR%\WinSxS" /i
    
    [...]
    43653 files within 8596 directories were compressed.
    6,021,146,695 total bytes of data are stored in 4,102,382,853 bytes.
    The compression ratio is 1.5 to 1.
    

    7. Restore ownership back to TrustedInstaller:
    icacls "%WINDIR%\WinSxS" /setowner "NT SERVICE\TrustedInstaller" /t
    
    processed file: C:\Windows\WinSxS
    [...]
    Successfully processed 44231 files; Failed processing 0 files
    

    8. Restore ACLs for WinSxS folder we saved earlier.

    Notice the command line doesn't specify WinSxS folder, but its parent (%WINDIR%) - it's because icacls stores paths starting with WinSxS in the .acl file; open up the file with Notepad or see more here.
    icacls "%WINDIR%" /restore "%WINDIR%\WinSxS.acl"
    
    processed file: C:\Windows\WinSxS
    [...]
    Successfully processed 44231 files; Failed processing 0 files
    

    9. Delete WinSxS.acl file (cleanup)
    del "%WINDIR%\WinSxS.acl"

    10. Restore Windows Installer and Windows Module Installer services:
    sc config msiserver start= demand
    sc config TrustedInstaller start= demand
    

    * * *

    Original (before)
    Compressed (after)


    Wednesday, December 26, 2012

    Windows: Keyboard repeat delay (short)

    One of the first few things I do on a new Windows installation is to change the keyboard repeat delay to short. It helps me with arrow navigation or backspace in code or text files, address bar or contents in web browsers etc. Some people get used to pressing a key repeatedly, but I like this one more.

    Go to Control Panel > Keyboard > Speed > Character Repeat > Delay

    Drag the slider to the right, then give it a test in the area down at the bottom.

     

    Saturday, October 20, 2012

    Macrium Reflect Free - restoring partition / disk backups

    Now with the disk backup and the rescue USB flash created earlier, we’re going through the restore process. I won’t do that on a real PC though but on a local VM, where I can take some screenshots.

    Macrium Reflect running on Windows PE looks pretty much the same as in the full Windows app (and it probably is the same :-). You can browse the network (in my case) or an attached USB drive for the disk backup image.

    1. Macrium Reflect - Restore, VM - Browse

    Choose the “Restore Image” option and that’ll take you to the restore wizard.

    Note: I’ve set up the VM display to 800x480 at first (ASUS R2H screen size) and I can see a problem as it cuts off the bottom of the wizard window. Maybe you can work around that if you learn the key sequences to push the buttons, but maybe the Windows PE might just support an external monitor you can connect through VGA? I’ve changed the VM screen to a 800x600 to move on.

    2. Macrium Reflect - Restore, VM - Partitions

    Select the physical destination disk and you can pick the partitions you want to restore and then click the “Copy selected partitions”. Here I will restore all 3 partitions, although you can use to only say restore the "personal” partition, and re-install the OS on the first partition later, or the other way around.

    3. Macrium Reflect - Restore, VM - Partitions, destination

    Click Next to get to a summary page, and then click Finish to start the restore process.

    4. Macrium Reflect - Restore, VM - Progress

    Leave it running, this will take a while. Although might look like like a long time, but it’s definitely shorter than having to re-install OS and applications, and certainly a lot less effort (and I should know, I’ve done this a lot).

    5. Macrium Reflect - Restore, VM - Finished

    Restart the system, and should now be fully restored to its previous state.

    6. Macrium Reflect - Restore, VM - Restored

    Now having used it end to end, I think Macrium Reflect Free is a great tool for a home user, and amazingly you get all that for free! Might sound odd, but I wasn’t paid for these last posts, I’m just genuinely surprised how easy it was and how well it worked to do exactly what I needed Smile

    Friday, October 19, 2012

    Macrium Reflect Free - bootable rescue media

    A day may come when your old hard disk might crash - or if like me, you might break things :-) - and you’d need to restore your system. The nice thing about disk / partition backups is that you can restore your system very quickly to the previous state with contents and all, rather than reinstall Windows and the rest of your applications.

    For that, we’ll be preparing a boot disk with the Macrium Reflect software – the software creates an .iso image you can write to a CD/DVD, or my preference is for a USB flash drive. If you only got a computer around the house, might want to do that early while your system is still usable, otherwise you can do that later when you need it.

    1. Macrium Reflect - Rescue Media - Main

    You have a choice between a Windows PE and Linux based disk – I tried the Linux image earlier and unfortunately didn’t seem to be able to connect to my Seagate GoFlex Home NAS. I can imagine the Windows PE supports a lot more network devices, so I’ll go for that.

    2. Macrium Reflect - Rescue Media - Wizard Step 1

    This option requires Windows Automated Installation Kit (AIK) – if you already have it downloaded somewhere you can just point to it (have used it before for Windows 8 PXE boot), otherwise the application will download it for you (1.7 GB).

    3. Macrium Reflect - Rescue Media - Wizard Step 2

    WAIK and image preparation finished, you can choose to burn it onto a CD/DVD or a USB flash drive.

    4. Macrium Reflect - Rescue Media - Wizard Step 3

    If you get the error message below when writing the image to the USB flash drive, follow the directions in this Macrium KB entry to prepare the drive and then try again.

    5. Macrium Reflect - Rescue Media - USB drive error

    I will go through the restore process using this newly created rescue disk in a new post soon.

    Thursday, October 18, 2012

    Macrium Reflect Free - disk / partition backups

    Have been looking for ages for a good free partition backup (imaging) software, and Macrium Reflect Free 5.0 does exactly what I wanted and even more – I’m quite surprised the free version has so many features really. While Windows Backup has improved quite a bit in the last Windows versions and handy for file backups, what I needed is an application to image entire partitions or disks and be able to easily restore the disk contents after a system crash. Another feature I was looking for is to have a bootable CD or flash drive so I can restore the system without the need for a full OS. I’ve been reading on the likes of Clonezilla, PING and DriveImage XML, but they just don’t seem very easy to use, especially on the last part - they are using Linux based boot images, mostly console based and they just don’t seem very friendly to use (here is a good start if you are looking into this).

    In today’s exercise I’m going to backup the entire disk of my ASUS R2H (all partitions), in preparation for installing Ubuntu 12.04 next week (mm, that’ll be interesting :-), but just as well you can choose one partition if you want to image them separately or some more often than others. The windows are a bit tall for the 800x480 screen (R2H), so I’m running it through Remote Desktop in 800x600 and it seems to fit just fine – it appears they did think of smaller screen computers, but not that small.

    The main interface is colorful and easy on the eye.
     


    I’m going to save the disk image on my Seagate GoFlex Home NAS on the network, but a USB hard drive should be just as good.


    The summary page has an advanced button (bottom left) where you can choose the compression level, split the image into separate files, enter a comment or choose to shutdown when finished, if you have to leave it running for longer on its own.
     

    Initial estimation is about 2 hours for the 60 GB disk (about 80% full) – the system is quite busy on the CPU, maybe the medium compression is a bit too much for the tiny Celeron. Grab a cup of coffee or find something else to do in the meantime :-)


    That was quite accurate, 2 hours later disk backup is finished – with an image file of about 40 GB.


    Now if you switch to Restore tab, you can see the image and you can choose to verify it…
     

    or, just above that (or from left tasks) you can choose to browse the image – that will mount a partition as read-only in Explorer. I see that very useful if want to pick a few files from an image, without the need for a full restore.
     

    That’s it from the backup perspective. There will be two other posts on how to create a recovery USB flash drive and how to use that to restore the backup we just did.

    Friday, October 12, 2012

    ExamDiff Pro: customizing display colours

    I’ve been using ExamDiff Pro for 9 years next week (funny how found that looking for the emails with the license to re-install on a new Windows :-) and it was probably the  best 30$ I ever spent, considering I’ve used the hell out ExamDiff Pro 3.x until recently upgraded to 5.5.

    It is an impressive piece of software you get for the money - file compare with differences at character level, ability to save the compare results as a portable webpage you can attach to emails with fully synchronized scrolling, looking at changes with and without customized ignores at a click of a button, command line support for scripting bulk compares, directory compare and merging, and recently found a feature I like, comparing files with ability to exclude parts (columns) using regular expressions, great for comparing logs with different date/time stamps, and the list could go on. Don’t get me wrong, I continue trying free alternatives out there and even use them in customer sites (like WinMerge for example), where I don’t have my ExamDiff Pro; but as a software developer, as soon as I got my first few checks I just had to look for better tools, and it did pay off in time savings and less effort.

    But this is not as much about the software itself, as it is about the presentation – I always thought the standard colours in the screenshots they have on the website weren’t doing the software any favours. I thought they were too bland and not very helpful. Maybe it’s just me, but if you do a lot of file comparing you probably want to spot the differences quickly enough to figure out what the changes are about.

    And not that you can only fully customize them, but you can also export the entire configuration as an Options.txt file to store away and simply import again on a new Windows installation or I don’t know, share them with yoru friends (obviously programmers as well :-).

    This is how the standard colours look like – I mean, look at the colour set: dark red is additions, blue is deletions, on a dark grey background, and then the entire block on a muddy yellow (?!)

    ExamDiff Pro - standard colors

    And here are my colours – I have additions as green, deletions as red on a bright yellow background for the modified text to stand out, removing the block background colour (set to white), to focus on the text changes themselves. I know the whole taste in colours is controversial, some people like one way and others like some other way, but I thought I might put it there - I know I changed mine quite late, on a slow Monday and kept them since :-)

    ExamDiff Pro - customized colors

    Thursday, August 9, 2012

    Squirrel SQL – cannot update on Windows with UAC enabled

    I had this problem before but I just worked around it by simply copying the updated installation from a Windows machine that didn’t have User Account Control (UAC) enabled – with SQuirrel SQL 3.4.0 update now available, thought I might look into it and see what’s causing the problems. Sure, if you are installing SQuirrel SQL into a folder somewhere that doesn’t require elevation, you should not have this problem – thing is I usually install it on Windows servers with UAC enabled and place it in %ProgramFiles%.

    First of all, obviously, you need to first run SQuirrel SQL elevated (right click > Run As Administrator), otherwise when using the update feature it will fail promptly, as it wants to download the updated .jars into a subfolder of Squirrel SQL home.




    Running Squirrel SQL as Administrator this time, will download the updates just fine.



    Now the problem is, if you close and restart SQuirrel SQL not elevated, it will prompt to install the updates, but will fail as it doesn’t have the rights to update the libraries.

    If you run it elevated though, it won’t prompt you to install the updates!!! Now that’s annoying…

    Process Monitor to the rescue (again) showing that SQuirrel SQL is looking for the listing file in %WINDIR%\System32\update ?! Odd alright… The javaw.exe process in Process Explorer shows something that explains it: the current directory of the elevated process is not the one specified in the shortcut, but %WINDIR%\System32 !



    Looking at squirrel-sql.bat it seems to prepare the home location into a UPDATE_PARMS environment variable, but maybe it’s not used by the application and it should be really added to the command line?!

    The quick solution is to add a change-directory command to the SQuirrel SQL home - that way it will work when running under normal privileges (the same working directory is coming from the shortcut), as well as when running elevated (when current directory is %WINDIR%\system32).
    SET UPDATE_CP=%TMP_CP%
    SET UPDATE_PARMS=--log-config-file "%SQUIRREL_SQL_HOME%\update-log4j.properties" --squirrel-home "%SQUIRREL_SQL_HOME%" %1 %2 %3 %4 %5 %6 %7 %8 %9
    cd /d "%SQUIRREL_SQL_HOME%"
    "%LOCAL_JAVA%" -cp %UPDATE_CP% -Dlog4j.defaultInitOverride=true -Dprompt=true net.sourceforge.squirrel_sql.client.update.gui.installer.PreLaunchUpdateApplication %UPDATE_PARAMS%
    I’ve added my findings to a related ticket:
    https://sourceforge.net/tracker/index.php?func=detail&aid=2759952&group_id=28383&atid=393414

    Update:

    D’oh! now I see it, thanks to Notepad++ word highlight feature! The environment variable is defined as UPDATE_PARMS, but the one in the command line is UPDATE_PARAMS! so I guess now you have two solutions :-)

    Monday, July 30, 2012

    Registry Editor - Adding favorites (bookmarks)

    This is a less known but very handy feature when you’re making repeated registry changes to test things, helping you to get very quickly to specific locations.

    For example every time I install a new Citrix Client I may have to uninstall the old one first and then go back and change a couple of registry keys (in this case to always send the Windows keys combinations to the remote desktop, pass-through ).

    The alternative is to export the entire branch from File menu and re-load at later time – that’ll export all sub-keys and values into a .reg file, which you can edit afterwards with say Notepad to keep only the ones you want to re-load later (just in case others may have changed and will not want to overwrite the entire branch).

    Regedit - Add Favorite

    Friday, July 27, 2012

    The case of… Oracle 11g Listener not starting (Windows)

    Just had this problem today where an Oracle 11g Listener wasn’t starting up and when eventually did start listening on port 1521, it wasn’t taking client connections! The odd part is that as far as I know nothing was changed, either software or network configuration, so why all this?! lsnctrl status was showing this error:
    C:\oracle\product\11.1.0\db_1\BIN>LSNRCTL.EXE status
     
    LSNRCTL for 32-bit Windows: Version 11.1.0.6.0 - Production on 27-JUL-2012 02:51:26
    Copyright (c) 1991, 2007, Oracle.  All rights reserved.
     
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server.domain.com)(PORT=1521)))
    TNS-12541: TNS:no listener
    TNS-12560: TNS:protocol adapter error
      TNS-00511: No listener
       32-bit Windows Error: 61: Unknown error
    Focusing with Process Monitor (procmon) on TNSLSNR.exe showed that it was trying to write to the listener.log file. Right-click the file and choose Jump To… brought the file in Explorer, wow, the log file is 4 GB?! Stopping the listener service, removing the log file and restarting the listener service, services are back to normal now!
    C:\oracle\product\11.1.0\db_1\BIN>LSNRCTL.EXE status
     
    LSNRCTL for 32-bit Windows: Version 11.1.0.6.0 - Production on 27-JUL-2012 02:52:49
    Copyright (c) 1991, 2007, Oracle.  All rights reserved.
     
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server.domain.com)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for 32-bit Windows: Version 11.1.0.6.0 - Production
    Start Date                27-JUL-2012 02:52:27
    Uptime                    0 days 0 hr. 0 min. 22 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   C:\oracle\product\11.1.0\db_1\network\admin\listener.ora
    Listener Log File         c:\oracle\diag\tnslsnr\SERVER\listener\alert\log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SERVER.domain.com)(PORT=1521)))
    Services Summary...
    Service "INSTANCE1_XPT" has 1 instance(s).
      Instance "instance1", status READY, has 4 handler(s) for this service...
    Service "instance1" has 1 instance(s).
      Instance "instance1", status READY, has 4 handler(s) for this service...
    The command completed successfully

    I guess now what’s left is trying to figure out how to reduce the amount of logging, it appears that it logs every connection being made, which eventually fills up the log and create the problem.

    […]
    27-JUL-2012 03:17:21 * (CONNECT_DATA=(SID=instance1)(CID=(PROGRAM=JDBC Thin Client) 
    HOST=__jdbc__)(USER=xxx))) * (ADDRESS=(PROTOCOL=tcp)(HOST=xx.xx.xx.xx)(PORT=53616))
     * establish * instance1* 0
    […]

    Monday, July 23, 2012

    Auslogics Disk Defrag

    I’ve been using Piriform Defraggler for quite a while now and I like it does a good job at defragging your drivers, has an easy to use user interface, can run on a schedule, and last but not least it’s still evolving and new features are added in – one example is the SMART tab, to see information like HDD temperature for which you would need otherwise a separate tool. On the down side I found that it can be slow when defragging larger files and the remaining time calculation is not always accurate and sometimes way off. I occasionally find the need to defrag some larger VM images and not knowing how long is it going to take frustrates me a bit – true, you can leave that for later for an unattended defragmentation and have the software shutdown your PC when done, but still...

    There are a few free alternatives out there and Auslogics Disk Defrag is just one of them, but what I like about it is that has similar features that I liked in Defraggler and in a way it looks similar (don’t all disk defrag tools do? :-)  Odd as it might sound though, I like the website (clean and easy to follow) and to me if the same level of attention is given to the software, that’s does it for me. On top of that, I like the fact that when defragging a larger file, it shows the number of clusters going through so you can see the progress being made.

    I’m sure Defraggler will improve and I might even switch back someday :-), but for now I think I’ll give Auslogics Disk Defrag a try and use it for a while as the preferred tool.

    Note: As with other free software, pay attention to the installation steps as it will ask you whether you want to install additional software like toolbars and the sort, it’s all up to you.

    Auslogics Disk Defrag

    Thursday, July 12, 2012

    Microsoft SQL Server 2008 R2 Express and compressed volumes

    On the earlier mentioned VM, I’ve compressed the entire volume to save some disk space, after creating the database. As I found later though, my SQL Server database wasn’t coming back online. Taking it offline and then bringing it back online with SQL Server Management Studio the reason became apparent – SQL Server does not allow for active database files to be compressed at file system level!

    The file "C:\...\database.mdf" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.
    The file "C:\...\database.ldf" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.
    Database 'database' cannot be opened due to inaccessible files or insufficient memory or disk space.  See the SQL Server errorlog for details.
    ALTER DATABASE statement failed. (Microsoft SQL Server, Error: 5118)

    And it appears for a good reason – database performance would be affected by the read/write operations on compressed database files and it could happen unknowingly just it happened to me – someone could compress the volume, performance is affected and everyone will be scrambling what might’ve happened to a production database! The compression was pretty good as well, my 8 GB database was only taking about 2.5 GB of space, you can imagine a much larger database saving a lot of space.

    Another important reason is database recovery, all explained below:

    In my case, I kept the volume compressed, but uncompressed my two database files (.mdf, .ldf), problem solved. Interestingly enough though, SQL Server doesn’t seem to apply the same restrictions to tempdb and master databases…

    Sunday, July 8, 2012

    The case of… breaking the WinSXS folder security rights

    Just had this problem the other day when having to re-install Microsoft SQL Server 2008 R2 Express (x64) on a Windows 7  SP1 (x64), the setup was failing with the error message:


    Microsoft SQL Server 2008 R2 Setup
    ----------------------------------
    An error occurred during the installation of assembly
    'Microsoft.VC80.CRT,version="8.0.50727.42",type="win32",processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b"'.
    Please refer to Help and Support for more information. 
    

    Searching the web for similar it appeared to be failing at installing Microsoft Visual C++ 2005 Redistributable package. Downloading and running the package on its own was showing the same error. After spending a lot of time digging through similar problems on the web with suggested solutions ranging from removing the *vc80* files from %WINDIR%\WinSxS and re-installing the affected packages to running the System Update Readiness Tool for Windows 7, nothing seemed to fix it. Trying a few things myself, bringing some of the related files over from a similar working system (ATL, MFC etc) into %WINDIR%\WinSxS, without much luck; taking traces with ProcMon watching for missing files, nothing.

    All until almost giving up, I thought it might be a permission issue – I did remember playing with WinSxX folder recently on that system (more about it below) so filtering again with ProcMon for msiexec.exe and ACCESS DENIED results, revealed this:


    msiexec.exe running under SYSTEM account was denied access to %WINDIR%\WinSxS\InstallTemp! Comparing the security for that folder to a similar working system showed that SYSTEM requires full rights there. Manually fixing the rights on that folder the installer has worked fine once again, problem solved.

    * * *
    Now, to the not so pleasant part where it shows that all this was due to my own stupidity, and hopefully a meaningful lesson for others.
    This was a VM with a somewhat limited amount of space and was trying to compress a few larger folders found with WinDirStat (tip: hide Treemap and File types from Options menu, you don’t need them), one of them being %WINDIR%\WinSxS. You can find a lot of forum posts where people complain about it growing to take a lot of space, and other people telling you to stay away from it. In my case, the folder was about 12.5 GB and compressing it reduced it down to ~8 GB, saving quite a bit of space.

    How did I do it? TrustedInstaller is the owner of the folder and a local Administrator won’t have the rights to compress – trying to compress it will give you a lot of Access Denied errors and if you ignore them all it won't compress anything. So I came up with these steps:
    • take ownership of the WinSxS folder in Windows Explorer > Properties > Security tab;
    • add my user with full rights and propagate the rights to the child objects;
    • compress folder (Windows Explorer > Properties > General > Advanced);
    • remove my user from the security list;
    • give ownership back to TrustedInstaller (NT Service\TrustedInstaller).

    In short this is what happened – normally SYSTEM account has only read/list rights on the WinSxS folder, but on WinSxS\InstallerTemp it has full rights (not inherited). When adding my user and propagating the rights to subfolders, it changed those full rights to read only, making the module installer fail later.

    The lesson I guess is, if you are not prepared to pay the price, stay away from that folder. Or maybe otherwise be persistent and experiment to understand what’s going on, but that might take a lot of time and effort, with sometimes very little gain - 4 GB of disk space for almost a day of frustrating trial & error.

    Sunday, July 1, 2012

    Running a command / application as Local System

    Occasionally you may need to run a command or application as Local System, say a service application that doesn’t produce enough log information and fails due to security rights.

    One way to do it is by scheduling a command through Windows Task Scheduler, as explained here:
    http://blogs.msdn.com/b/adioltean/archive/2004/11/27/271063.aspx?Redirected=true

    But I find easier to use psexec.exe from Sysinternals’ PsTools package.
    http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx

    Not only you can run an application locally, but you can also use it to run it on another machine remotely; run psexec without parameters to get a list of options.

    psexec –s cmd.exe

    psexec - local system

    Wednesday, May 30, 2012

    RAMMap – Freeing up memory

    http://technet.microsoft.com/en-us/sysinternals/ff700229.aspx

    I found RAMMAP very useful in debugging memory usage scenarios where due to various file operations (copying files around, enlarging VMware Player virtual disks etc) a lot of memory would go into Standy, and then subsequent operations that would require large amounts of what I assume would be contiguous blocks of memory, like archiving large VM images with 7zip, would fail.

    From what I understand Standy contains memory pages that were used by the cache manager and they are still kept around in case you might be opening the same file again, instead of reading it off the disk again it can activate it back from standby – it’s also the thing that makes the memory values not add up in Task Manager, as it is counted in both Cached section as well as Available, and Window will free up and zero these pages as needed.

    Windows 8 is the first version to show it separately in Task Manager and make things clear:


    Back to RAMMap, it shows everything in detail, as explained in this post:
    http://blogs.technet.com/b/askperf/archive/2010/08/13/introduction-to-the-new-sysinternals-tool-rammap.aspx

    The part that I discovered lately is where RAMMap allows you to empty different sections and gain back some memory – how you can benefit from that? Say you need a large amount of free / zeroed memory or you want to performance test your application and clearing the cache working set or standby would give you a “cold” start.

    The “Empty” menu gives you a few different options – if you start from the top and go through the options, it will give you most of the memory back, but you’ll have a slight performance hit as the system will recover. In most cases you might just want to choose the last two, clearing just the Standby lists.


    On a 4GB Windows 2008 R2 Server:


    The same system after emptying all sections – notice the large amount of free (zeroed) memory.