Archive for January, 2008
Fix Cut And Paste Problems With Remote Desktop
Remote Desktop is one of the best features of Windows. Unfortunately all the different Windows version of Remote Desktop seem to have a copy and paste bug. Pasting from the local machine to the remote machine in Remote Desktop will just randomly stop working.
I’ve been plagued with this problem for a long time but I never found a way to fix it. Now I found a simple method that works: On the remote machine kill the rdpclip.exe task and restart it. Pasting will immediately start working again!
Kill the rdpclip.exe task whichever way you want. You can use Task Manager, or you can use this one line command to kill and restart it automatically.
taskkill.exe /im rdpclip.exe & rdpclip.exe
Automatically Install Definition Updates for Windows Defender
One of the benefits of Windows Vista is that it has built in spyware protection with the Windows Defender tool. Defender has frequent updates much like virus scanner products. Frequent updates are good, the annoying thing is that every time there is an update, Windows Update pops up in the task bar and asks you to install the latest update. Because I have Windows Updates set to not install automatically, this requires a few clicks every few days. I always wished there was a way to install the Defender updates automatically.
I finally figured out how to make this happen. It turns out that Defender is scheduled to automatically download updates at 2am every day and then scan your machine. This is great if you keep you machine on 24 hours a day. But I put my machine in hibernate every night to save electricity so the scheduled process rarely gets run. This means that the Defender updates don’t get downloaded automatically causing Windows Update to prompt me to install them.
To fix this just schedule the scan to occur at a time when you are more likely to be using the computer. My computer is usually on in the evening so I set Defender to scan daily at 9pm. This way the updates will get downloaded automatically when the computer is most likely to be on. And I haven’t noticed much of a slowdown of Vista when the scan is running.
Here are details steps on how to enable the automatic definition updates:
Outlook Automation Error When Connecting From Elevated Prompt
One thing I didn’t realize until the other day is that a Vista command prompt that is elevated is unable to control Outlook. I was testing some JScript code from an elevated prompt and got this error:
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Users\psheed\SendMail.js(1, 1) Microsoft JScript runtime error: Automation server can't create object
Unfortunately the error message isn’t very helpful in diagnosing the problem. After trying a few things I eventually found out that the script would work fine if it was running from a non-elevated prompt. Now it makes sense, you can’t use code that is running elevated to control non-elevated code for security reasons.
Recursive add all files in a directory with Perforce
Posted by Patrick in Random Software Tips on January 15, 2008
It is very common to want to add a directory of files to your source control system. With Perforce the command line client doesn’t support this natively. I would think that a command like this would work: “p4 add …”. But unfortunately Perforce displays this non-useful message when you try that:
Can’t add filenames with wildcards [@#%*] in them.
Use -f option to force add.
Instead you have to use a one line shell command to do this. On Windows try this:
“dir /b /s /a-d | p4 -x – add”
For non-Windows platforms you’ll have to do a similar command. Just change the ‘dir’ part to whatever you use to display files in your OS.
Multi-line Search and Replace in Visual Studio
Posted by Patrick in Visual Studio on January 14, 2008
Often it is useful to do a global search and replace in a directory of files. For a search string on a single line this is trivial. Just hit Ctrl-Shift-H or “Edit -> Find and Replace -> Replace in Files”. Then enter the necessary information and do the replacement.
It becomes more tricky when you have a multiline search or replacement string. With the standard options in the search and replace box you can’t do this. But select Regular Expressions in the Find Options section and a multi-line string becomes possible.
Now you can use Regular Expressions in the search. Enter your search and replace string as normal but enter ‘\n’ where you want a newline to appear. Visual Studio can now find and replace multi-line strings!
Improved Command Prompt For Windows Cmd.exe
This is a very useful tip for anyone who regularly uses the Windows command line. The default cmd.exe prompt displays the current path on the same line that is used for input. When you are in a deep directory you don’t get much room for typing. The other problem is that the default prompt has a “>” symbol directly after the path which causes a problem when cut and pasting the current path into other windows.
You can have an improved command prompt like this:
The quick way to test this change is to enter this command at the prompt: “set prompt=$C$S$P$S$F$_$+$G$S”. The improved prompt will be enabled in the current window until it is closed.
To make the change permanent and enabled in all new cmd.exe windows:
- Windows Key + R.
- Type “sysdm.cpl” and press enter.
- Select the Advanced tab.
- Click “Environment Variables”.
- Click “New” to add a new user variable.
- Add variable name: PROMPT
- Add this value: $C$S$P$S$F$_$+$G$S
- Exit out of everything.
Now every cmd.exe window that you open will have the enhanced prompt. This gives you some benefits:
- More room to type your command.
- Separation between the current directory and the typed command.
- Double click on the current directory and paste and you have a valid path without modification.




