Tags: windows

Walle

Debugging VBScript from Notepad++ in Windows 7

Notepad++ is a very nice editor for VBScript. If you open a .vbs file with it, the syntax will automatically be highlighted because VBScript language support is already built in.

With only a few steps, you can also invoke the debugger of your choice from within Notepad++, which makes it easy to edit your script, test it and edit some more without having to manually switch between different tools.

You can call Wscript.exe for debugging VBScript from Notepad++ in 64-bit Windows 7 as follows:
Go to folder %APPDATA%\Notepad++.
You should find a file named shortcuts.xml there. At the end of node <UserDefinedCommands>, add the following key:
<Command name="Debug VBscript" Ctrl="no" Alt="no" Shift="no" Key="0">%WINDIR%\SysWOW64\wscript.exe /D /I /X &quot;$(FULL_CURRENT_PATH)&quot;</Command>
Now you can start the debugger from the Run menu of Notepad++.

A few remarks:
Notepad++ overwrites shortcuts.xml on shutdown, so you should use a different editor for this change, while Notepad++ is closed.

For some reason, the 64-bit version of Wscript.exe will just run the script without stopping for debugging. That's the reason the 32-bit version residing in the SysWOW64 folder is being called.
If you want to set Windows to always use the 32-bit version for handling .vbs files, you'll have to change the path to Wscript.exe under the registry path HKEY_CLASSES_ROOT\VBSFile\Shell\Open\Command. The (Default) value will read something like "%SystemRoot%\System32\WScript.exe" "%1" %*. Leave the value intact but change System32 to SysWOW64.

For further information about shortcut.xml, find a detailed description here.

Under Run -> Modify Shortcut/Delete Command... you can assign a shortcut to invoke the debugger in Notepad++. Alternatively, you can set the parameters Ctrl, Alt, Shift and Key in the String that you add to shortcuts.xml.
Walle

VBScript: Getting a File Browse Dialog in Windows 7

If you need a file open dialog in a VBScript, you have plenty of possibilities in XP to do it quick and easy. In Windows 7, however, they don't work anymore. Google found me a few ways to get a file dialog in Windows 7, but they all had flaws like not working for all file types, or not being able to be starting in a pre-set folder, or only returning the file name, not the full path, or needing ActiveX components that I just couldn't get to work.

In the end, I found jsShell, which provides dialog windows that just do what you expect them to do and are easy to use. And even I was able to get them to work.

Of course, there're a few steps needed to enable them:
  • Download jsShell.zip (180 KB) and unpack it.
  • In order to work in 64-bit Windows, move jsShell.dll to %WINDIR%\SysWOW64 (usually %WINDIR% is C:\Windows). Do NOT use System32!
  • Register it to Windows:
    Right-click cmd.exe - Run as Administrator and type
    cd \%WINDIR%\SysWOW64 <Enter>
    regsvr32 jsShell.dll <Enter>
  • Set Windows to use the 32-bit version of WScript for .vbs files. In the registry, there should be a path HKEY_CLASSES_ROOT\VBSFile\Shell\Open\Command. The (Default) value will read something like "%SystemRoot%\System32\WScript.exe" "%1" %*. Leave the value intact but change System32 to SysWOW64. That will cause the 32-bit version of WScript.exe to handle .vbs files.


  • Once you've set it up, you can invoke a file browser dialog in VBScript like this:

    Dim objJs

    Set objJs = CreateObject("jsShell.Ops")
    myFile = objJs.OpenDlg("Select file", "txt", "C:\MyStuff")

    (See also the demo scripts coming with jsShell.zip)
    beads, Dalek

    Text Files From Windows to Android

    I used to have a list of all movies we own in my Palm Pilot, so in case we were shopping and stumbled on DVDs on sale, I could check if we already had a certain movie or not. Now that the Palm is retired, I tried to get this list in my Samsung Galaxy S2.

    I decided to use the Memento Database app for my movie list, because I don't need a super fancy movie management app with lots of unnecessary bells and whistles, a simple DB table is more than sufficient for my needs.

    Unfortunately, it wasn't as easy as copying the csv file to the phone and import it to Memento. The special characters, e.g. umlauts, all got mangled, and there were too many entries to fix them manually on the phone.

    A bit poking around revealed that the importer was fine, the file got already screwed up when it arrived on the phone. Turned out the character encoding was wrong - it was ANSI because it came from a Windows computer and Android uses UTF-8.

    NotePad can also save files in UTF-8 (the SaveAs dialog has three fields - file name, format, and character encoding), but now the file looked good on the phone but Memento only imported empty records.

    A bit more poking around finally led me to NotePad++, a free text editor. Besides UTF-8, it also has an encoding option UTF-8 without BOM and that was it. After saving the csv file with this option, the umlauts arrived safely on the phone and everything got imported correctly into Memento :o)

    ETA: I wrote a VBA macro that creates a correctly formatted and encoded csv file from an Excel sheet and posted it here.
    Walle

    Finding Stuff in Windows 7

    I'm probably one of the last people on earth going from Windows XP to Windows 7, so this is more a reference for me than any help for others, but there you are:

    Where to find a few things in Windows 7

    User settings
    The folder ...\Documents and Settings\<Username>
    is now ...\Users\<Username>

    SendTo folder
    The folder ...\Documents and Settings\<Username>\SendTo
    is now %APPDATA%\Microsoft\Windows\SendTo

    Change the background picture/color for your user:
    Right click on screen -> Personalize -> Desktop background

    Change the background picture of the logon screen:
    Start -> Run -> regedit
    Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background
    Set the DWORD value named OEMBackground = 1
    (If it doesn't exist, create it. And of course be careful when tampering with the registry and back it up first if you're unsure!)

    Create folder C:\Windows\System32\oobe\info\backgrounds, put the picture there and name it backgroundDefault.jpg
    The file should be less than 256 KB and the resolution should be the same as the screen resolution, or it'll auto-adjust to fit the screen.

    Change the shadows for the text on the logon screen:
    Start -> Run -> regedit
    Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI
    Set the DWORD value named ButtonSet to one of the following:
    0=Light shadow, 1=Dark shadow, 2=No shadow
    (If it doesn't exist, create it. And of course be careful when tampering with the registry and back it up first if you're unsure!)

    Enable Quick Launch toolbar
    Right click on Taskbar -> Toolbars -> New Toolbar...
    Enter in Address Field: %userprofile%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch
    Press Select Folder

    Enable Recent Items
    Right click on Taskbar -> Properties -> Start menu -> Customize -> Recent Items

    Enable Address toolbar
    Windows 7 has brought back the Address toolbar that went poof with Windows XP SP3, yay!
    Right click on Taskbar -> Toolbars -> Address

    Change icon size for Taskbar icons
    Right click on Taskbar -> Properties -> Use small icons (or not)

    Change icon size for Taskbar toolbars' icons
    Unlock Taskbar, right click on now visible toolbar handle -> View -> Large/Small Icons
    (small icons are smaller but the rows have the same height as large icons, but at least they aren't as wide)

    Show menu bar in Windows Explorer
    To temporaily view the menu bar, press Alt
    To permanently view the menu bar, press Alt and select Folder Options -> View -> Always show menus

    Map Network Drive in Windows Explorer
    Tools -> Map Network Drive

    Enable folder tree view in Windows Explorer
    Tools -> Folder Options -> General
    Select both Show all folders and Automatically expand to current folder

    Quick change of thumbnail size in Windows Explorer
    Hold Ctrl and move the mouse wheel to increase/decrease icon size
    (this also works for icon size on desktop or font size in browsers, so pay attention to where your focus is)
    Walle

    Things You Notice by Coincidence

    Usually, when copying files with the Windows Explorer, I select the files, then drag them to the destination holding the right mouse button pressed. When releasing the button, a popup appears asking if I want to move/copy/create shortcuts and I select "copy".

    Today, I was a bit absent-minded and pressed Strg while dragging the files, not the right mouse button. It worked but left me wondering briefly why the popup didn't appear until I realised what I did.

    Ok, so this should be obvious. Many Microsoft applications use Strg+drag'n'drop for copying, so why should the Windows Explorer be different? Still I never hit on that idea...
    Walle

    WindowsXP SP3 Takes Away the Address Bar

    There's not much that is really handy and very useful in MS products, so why does MS have to take away the little that is?

    I use the address bar in the taskbar a lot, so when I got my new work Thinkpad, one of the first things I switched on was the address bar in the taskbar. Didn't get suspicious when it wasn't available in the list of toolbars. I could still activate it from the Quicklaunch bar that I've placed on the upper edge of the screen (in hindsight, I think this may be an oversight of MS that this is still possible) and then drag it down to the taskbar. But I got suspicious when I found that always when I logged off or restarted the computer, the address bar disappeared.

    With some googling, I found that apparently Microsoft removed the address bar from the taskbar with SP3, and surprise, surprise, my new Thinkpad is on SP3. While it's still possible to get the address bar back, Windows won't save this setting. Arrrgh!

    Fortunately, there're solutions to this problem and you can get the address bar back for good. I installed the tool from Niversoft and it works fine.
    Hello again, address bar :o)