Showing posts with label Vista. Show all posts
Showing posts with label Vista. Show all posts

Thursday, June 5, 2014

Computer on/off event viewer filter

Sometimes I want to track when I turned my computer on or off, including when it went to sleep or woke back up again.  To do that, I have created a custom view in Event Viewer on my Windows 8 system (should be the same for all systems from Vista and beyond, I assume). Go to Custom Views and click on "Filter current custom...". Switch to the XML tab and check the "Edit query manually" in the lower part. Now, paste the following in there:

<QueryList>
  <Query Id="0" Path="System">
    <Select Path="System">
    *[System
        [Provider
            [@Name='Microsoft-Windows-Kernel-Power'
            or @Name='Microsoft-Windows-Power-Troubleshooter'
            ]
            and TimeCreated    [timediff(@SystemTime) &lt;= 2592000000]
        ]
    ]
        or
    *[System
        [Provider
            [@Name='Microsoft-Windows-Kernel-General']
            and ( (EventID &gt;= 12 and EventID &lt;= 13) )
            and TimeCreated    [timediff(@SystemTime) &lt;= 2592000000]
        ]
    ]
   </Select>
  </Query>
</QueryList>

Basically, it is the equivalent of this, but only showing event 12 (switch off) and 13 (switch on) for the Kernel General source:




Please remember to "Save filter to custom view" if you want quick access to it later.

Friday, December 9, 2011

Administrator cannot change, delete or take ownership of file

Problem: It is well known that if a file is locked in Windows, an administrator can take control of the file by taking ownership of it, give himself permissions to write/delete it and then perform pretty much anything he needs to do with the file. Sometimes, however, you just receive an error message when you try to take ownership, even though you are an administrator, and even though the command prompt or Windows Explorer you are working from has been started by right-click - "Run as administrator"

Solution: Open Computer Management and open shared folders - open files. If the file in question is being held by someone that has opened the file over a fileshare, you first have to terminate their connection to the file before you can manipulate it. Of course, you should first make sure you are not disturbing any work they are doing on the file.

Monday, September 5, 2011

ODBC 32 vs. 64 bit

Scenario: I needed to connect 32 bit software running on a 64 bit Windows 7 OS to an SQL server via ODBC. Using a User DSN, everything was fine - setting up a System DSN instead, the application could no longer find it or and connect to the database. I preferred setting up a System DSN, so that any user logged on to the computer would be able to run the software without further hassle in setting up the needed ODBC connection.
Cause: An ODBC System DSN in 32 and 64 bit versions are two separate matters, hence a 32-bit application will not see a 64 bit ODBC System DSN and vice versa. User DSNs are however visible on both sides. Confusing.
Gotcha: Both the 64 and 32 bit version of the ODBC tool's is named odbcad32.exe. Hence, the Win7 standard method of writing this in the search field at the bottom of the start menu would always give you the 64 bit version. You have to run %windir%\syswow64\odbcad32.exe (for instance via the run dialog, keyboard shortcut winkey-r) to start the 32 bit ODBC application.
Reference: Microsoft's Knowledge Base article 942976

Wednesday, June 4, 2008

VB.NET: Shell32 code compiled on Vista does not run on XP/2003

This was a tricky one, and I had a hard time finding a working solution. I finally found the solution by reading comments in differnt forum. I had to mix it together myself - here's the finished soup:

Situation: I had a VB.NET code that was based on VBscript code from "Hey, scripting guy" to programmatically pin shortcuts from the desktop onto the start menu. This line of code created a bit of a headache:

Dim oShell As Shell32.Shell = New Shell32.Shell
Dim oFolder As Shell32.Folder = oShell.NameSpace(0) '0 refers to user desktop

Problem: The code compiled and ran on my Vista computer, but once I moved the .exe file to a Server 2003 computer, it threw a runtime exception stating: Unable to cast COM object of type 'Shell32.ShellClass' to interface type 'Shell32.IShellDispatch5 and then the usual garble (actually, the garble did reveal the line of code in question)

Cause: The Shell32 library comes in a new version in Vista compared to XP/2003 - or that is my conception of what I could find on the subject. The problem is that under XP/2003, the Shell32.ShellClass is not casted to Shell32.IShellDispatch5, but to its predecessor, Shell32.IShellDispatch4. Now I knew the difference, but it meant that the program needs to reference the right one.

Solution: I found the two first lines of code below buried in a comment in a forum - when they replace the first line of code above, voilla: It works on all platforms (the term 'all' referring to XP, Server 2003 and Vista):

Dim ShellAppType As Type = Type.GetTypeFromProgID("Shell.Application")
Dim oShell As Object = Activator.CreateInstance(ShellAppType)
Dim oFolder As Shell32.Folder = oShell.NameSpace(0) '0 refers to user desktop

Nerds like me may be simple to please - it certainly made my day!

Monday, January 14, 2008

Windows Photo Gallery would not open a file on the desktop

Situation: I often use the desktop for temporary storage of images or documents I am going to throw away after a very short while. When I tried to open a JPG image on the desktop by doulbe-clicking it, there was no reaction however. Standard program for viewing images is the Vista native "Windows Photo Gallery."

Problem analysis:
  • Doubleclicking the image or rightclicking, selecting preview or open with - Windows Photo Gallery all produces the same result: Nothing
  • Doing the same on another file residing in any other folder works perfectly.
  • Moving the image file in question to any other folder makes it open like a dream. Moving it back restores the problem.
  • Rightclicking and selecting open with - also works.
  • Rightclicking and selecting open with - choose default program makes the file open in the other program you choose upon doubleclick or richtclick - preview.
Problem identification: Windows Photo Gallery has a problem opening image files residing on the desktop.

Clue: On a web forum I found a clue that it might be due to another file on the desktop being corrupt. He suggested moving all files except the image file(s) on the desktop to a folder on the desktop. Having done that, IT WORKED AGAIN! I had moved away a couple of PDFs and two internet shortcuts, that did the trick. By moving one and one file back, I was able to identify one of the internet shortcuts as being my problem:

Solution: An internet shortcut containing a very long URL (a direct pointer to an online shipment tracker) was a showstopper. Removing this shortcut from the desktop did the trick.

I figure it must be some kind of a buffer overflow issue or something.

Wednesday, January 2, 2008

Web browsing stops working; ping, skype, nslookup etc. still fine

I believe I have got another Vista hate item on my list: Every now and then, particularly after some time of heavy browsing, the web browser suddenly stops working. Ping, nslookup and Skype still works, but neither Firefox, Internet Explorer, Thunderbird or FTP (from CMD) work any longer.

Investigation: A net trace using Ethereal Wireshark reveals that using IE or Firefox, no packets are ever leaving the browsers when I try to make a request for a web page. Obviously, there's something wrong in the internal OS parts that prevent packets from ever being created. OS parts because the problem applies to both IE, Firefox, Thunderbird and FTP (and more?) - OS is what they all have in common.

Possible solution: There's a lot of rubbish advice out there on different forums and blogs that advice to reset routers, disabling firewalls etc., which does not address the problem at hand. My best clue yet is Microsoft KB937168, which describes a problem pertaining to those with ICS (internet connection sharing) enabled. I happen to have just that.

Microsoft has a rigorous process for downloading the needed update, however The Hotfix Share seems to provide what is needed (if you can afford the risk of downloading from another site than Microsoft itself).

I will update this post when I have some certainty as to whether the problem is really solved - i.e. after hours of successful browsing without any hickups.

UPDATE 14.1.08: Problem is still gone - I am terminating this as an "under research" topic, assuming that the solution is found.

Friday, December 14, 2007

Things they stole back in Vista

(Originally posted Nov. 25, 2007 - the the list of complaints keeps on growing...)

If this continues, I will have torn all my hair off in pure frustration as to what Microsoft decided I do not need. It turns out that Vista (as in my Vista Business) has taken away several features that I had gotten used to in standard Windows XP. Aaaaargh - this just makes my point as to whether to choose a freely developed OS, with freely available features thrown in (Linux), or yet another time stay with so-called (un)supported licensed software. Enough said, here's my frustration list:

  • Backup is gone! That is, they did add some substitute only good for backing up your whole disk to an external source. What I used to do in XP was backing up a subset of files (my data) to a local file destination, and then took that file and burnt it to a CD for offsite storage. Forget it - the old NTBackup software is gone. I found a good substitute in the free Simply Safe Backup software, but that's beside the point.
  • Telnet is gone! Not too much of an alarm though, I found it under Control Panel-Programs and features-Turn Windows features on or off.
  • Windows Explorer no longer lets you completely turn off the "Remember each folder's view settings" (although the choice is there under Tools-Advanced). When I browse the folder hierarchy, I normally choose to see file details. If Explorer decides to however, it just jumps to thumbnail view, I guess when you enter a folder where graphics files are present. You'll also notice that they took away the "up" button to go one level up the directory tree. You can always go "back" to the previous folder you visited, but that's not always the parent folder. And of course, there's no way to customize the toolbar to bring that button back...
  • The defragmenter has lost the little that was left of its visual interface (it had already suffered the transition from 9x to XP badly). Luckily, there are good third-party tools out there, like the free Defraggler, that shows you where each file is located on the disk and even gives you the option to only defrag the files you need quick access to. With the new "improved" Windows, this is a necessary addon.
Apart from that, I found a couple of tricks to be most necessary to get around:
  • Run as administrator seems to be the general medicine if a program fails to do what you expect it to. Especially programs that access any part of the computer other than your screen/desktop (like registry, folders for programs, network ports etc.). I guess this is part of the new security model requiring you to say that you are sure a dozen times before actually doing what you are sure you want to do.
    • Ethereal Wireshark network packet tracer needs to be run with this option - otherwise you will not find any network adapters to inspect.
    • DevPHP had to be run as administrator to avoid loosing all settings upon exit. Assumingly this has to do with the new way Microsoft has invented to handle writing to the HkeyLocalMachine hive of the registry - where you THINK you write to that key, whileas actually writing to your HkeyCurrentUser hive. This is not comfirmed though.
  • Check out this brilliant website for clues: Vista Rewired -It made it right into my group of favourite bookmarks!
If Microsoft could just do a little bit more than pleasing newbies to Windows (do they?) and let us nerdies also have a few goodies, they might actually have some of us recommend their stuff. As for now, I sincerely hate Windows Vista and recommend everyone (including my customers) who buys a new computer to stick with XP. Vista is just a really bad idea.