A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Windows 10 robocopy basics

robocopy c:\temp\source c:\temp\destination /E /DCOPY:DAT /R:10 /W:3

Windows command prompt get set environment variables

Yuck. I feel dirty writing about the Windows command line, but sometimes you just need to get a job done.

View all environment variables

reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"

View a specific environment variable, e.g. PATH

reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PATH

Set an env var locally (not persistent)

set FOO="foo"

Set an env var globally (persistent) - must be run as administrator

setx BAR "bar" /M

View individual local env vars

echo %FOO%

echo %BAR%


Type GBP symbol without numeric keypad

Full size keyboard numpad method

If you have a numeric keypad to the right of you keyboard, you can type Alt+0163 to get a UK pound sterling symbol on a US-keyboard.

Modern laptop numpad method

Some laptops use a Fn (function) key and overlay the numpad on the main keyboard - so on a Dell Latitude I can hold Alt+Fn and type MJOL (which corresponds to 0163) to get a £ symbol.

...but some modern laptops don't have a numeric keypad at all. For those situations, see below.

Keyboard language switch

Install a UK keyboard alongside the US keyboard in control panel, and then type Win+Space to switch between them. Probably Windows 10 only.

Shift-3 usually types a # (hashtag) when set to US keyboard, and a £ (pound sterling) when set to UK keyboard.

Windows 10 character map (May 2019 update)

Type Win+. (dot) and you'll get a character map with all the symbols you'll ever need! 😊

It even remembers the ones you've used recently for quick access. (❁´◡`❁)

For faster keyboard navigation you can press [Tab] to cycle through the controls and [Enter] to select.

Old Windows method

Open the character map application from the start menu. You can search for it in the latest Windows, or it may be hidden in the Accessories folder for older versions.


Batch deleting files in Windows

List all the jpg files:

dir /s *.jpg /b > jpgs.txt

Delete all the jpg files:

del /s /q /f /a *.jpg



Why not to use a pop-up window

If you're using a pop-up window on your website, you're doing it wrong.
It's akin to using nested tables for display, fer chrissakes!

Reasons why it's wrong:

  • It's a poor user experience because the user doesn't get any of the usual browser functionality in the pop-up window, like the back button or the icon that tells you the page is loading.
  • I'm sure I'll think of some more later

Windows: folder or file open in another program

When you try to move a folder:

    "The action can't be completed because the folder or a file in it is open in another program"

This stunningly unhelpful error message has persisted through many versions of Windows.

The way I work around it is:

  • Rename an unrelated file or folder nearby, then rename it back again.
  • The original folder or file should now be "unlocked"
You can always reboot to fix it, too.

Linux window managers

Window managers:

  • Mate (fork of Gnome 2),
  • Mint (Extensions for Gnome 3),
  • or Cinnamon (Fork of Gnome 3)

Gnome 2 was good, Gnome 3 was where it all went wrong, but now people are switching back to Gnome 3.

See also evilwm (joke) or xfce (supposed to be fast).

When Ubuntu's window manager went bad (11.04 -> 11.10)

(source)

Prevent Windows from restarting after an update

Windows Vista/7: Start > search for gpedit.msc. Navigate to Computer Configuration > Administrative Templates > Windows Components > Windows Update and enable "No auto-restart for scheduled Automatic Updates installations".

All non-Home users can apply the same policy change by adding a new key to the registry. Go to Start > Run/Search for regedit. Navigate to HKEY_LOCAL_MACHINE SOFTWARE Policies Microsoft Windows WindowsUpdate AU. Create a new 32-bit DWORD value named NoAutoRebootWithLoggedOnUsers and give it a value of 1.

(source)

Outlook 2007: Don't remove line breaks

Microsoft :'-(

Outlook 2007:
Tools | Options | Preferences | E-mail Options
Untick "Remove extra line breaks in plain text messages"

(source)

How to transfer files between Windows 7 and Android 4

Settings | Storage | (three dots in top-right) | USB computer connection | Camera (PTP)

Then go to Developer Options (read elsewhere how to get this), and tick 'USB debugging'.

Voila - your device will appear in My Computer | Portable Devices.

Copy the files to a subdirectory of the Android Camera device in Windows, and move them into the right place from within Android. e.g. using ES File Explorer

Outlook 2007 reminder windows always on top

Hit Alt-F11, navigate to Project1 | Microsoft Office Outlook Objects | ThisOutlookSession

Simple way 

Private Sub Application_Reminder(ByVal Item As Object)
    If TypeOf Item Is AppointmentItem Then
    MsgBox "Message text", vbSystemModal, "Message title"
    End If
End Sub


(source)

Sophisticated way

Private Declare PtrSafe Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare PtrSafe Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal X As Long, ByVal Y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const FLAGS As Long = SWP_NOMOVE Or SWP_NOSIZE
Private Const HWND_TOPMOST = -1

Private Sub Application_Reminder(ByVal Item As Object)
Dim ReminderWindowHWnd As Variant
On Error Resume Next
ReminderWindowHWnd = FindWindowA(vbNullString, "1 Reminder")
SetWindowPos ReminderWindowHWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS

End Sub

(source)

How to forward your SSH key

Windows:

1. Run pageant, put it in startup, and pass it your key

2. Run putty or MobaXterm, configure them both to do "ssh -A" (i.e. forward your key)

3. On the server, check your SSH key is loaded:

ssh-add -l

4. ssh -A to other servers

Linux:

ssh -A to each server


Your PC does not need dynamic wallpaper or a health check

Do not install any of the following types of programs, they are almost guaranteed to be spyware, slow down your computer, and be difficult to remove:
  • Dynamic wallpaper/screensaver
  • PC health check
  • Speed up your PC
  • Clean your PC
  • Any new special anti-virus program (you should only have one trusted anti-virus program)
  • Defrag your computer
Instead, use Ad-aware or Spybot Search & Destroy to keep your Windows computer clean.

Windows "add or remove programs" list is empty

First of all, just wait for a few minutes. The list may appear after some time.

If still no luck:
  • Highlight and copy the entire bolded text below: 
    • cmd /c REGEDIT /E "%userprofile%\desktop\uninstall.txt "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ 
  • Click on Start > Run and paste in the text you have just copied. Hit Enter. 
  • A notepad document should appear on your desktop called uninstall or uninstall.txt 
  • Open it to view the contents
    • Look for the "UninstallString" values and copy those into the Start > Run box to uninstall programs


Thanks to tomshardware.co.uk

How to manage problematic application windows in Ubuntu

In Ubuntu:

To find out what application a window belongs to: Type xwininfo in the console, then click on the window.

To kill a window, type xkill in the console, then click on a window to kill it.


Good FTP clients

  • WinSCP (Windows)
  • WS FTP LE (Windows)
  • FileZilla (Windows, Linux)
  • FireFTP (Windows, Linux)

Macro recorders for Windows 7

Testing on Windows 7 Pro (SP1), in a Virtual Box (VM) window, running under Ubuntu 11.04.
  • AutoHotKey - scripting only, but users have built a recorder too.
    • Overall good. Free.
    • Steep learning curve, but users on IRC channel are very helpful
    • Note: Trying running program in "Administrator mode" if it doesn't seem to work.
    • How to develop scripts:
      • Use Recorder to get basic outline
      • Use included Window Spy to get precise coords (set "CoordMode, Mouse, Screen")
      • May need to fiddle with WinActivate parameters
      • Put sections of functionality into subroutines and test them individually
      • Use TrayTips as debug output
      • Make sure you make the script Sleep for at least 300ms between each action
  • Quick Macro - Couldn't get it to work. Shareware.
  • Auto Macro Recorder - Couldn't get it to work, either. Shareware.
  • PC Anywhere - Couldn't even download it.

How to use single quotes in a Perl one-liner

perl -le'$q=chr(39); print "quote mark: $q" '
(linux)

How to change a shape type in Visio

Install the "Super Utilities and Tools" add-in from Paul Herber's Sandrila Ltd.

Use the 'Shape | Substitute' command.