Tag: Windows

Maximum number of characters in a Windows path is 260 characters

A Java project compilation went berserk and I ended up with a directory structure of more than 260 characters. I stopped the mad process but it already created more than 50 successive duo of path “build/classes” …

Duo of build/classes directories in path created by Netbeans

Now I had to delete this structure. And, to my surprise, it was impossible. When you try to just press the “Delete” key with the root directory selected in the File Explorer, you get a Path Too Long exception. The reason is that the maximum length of a path according to the Windows API (MAX_PATH variable) is defined as 260 characters. I tried some other methods but all of them failed:

  • write a small Java program that tried to delete the whole path: Netbeans (Java) was able to create this mess, why shouldn’t another Java program be able to delete it? Impossible.
  • write a small C++ program that tried to delete the whole path: as long as you stick with the Windows API, it’s impossible (I read that it could be possible using the boost::filesystem library but didn’t try).
  • try some Portable Apps utilities for file management: impossible (even when the software was using another framework like Qt).

Finally, I just ran a Cygwin terminal, went to the ad hoc location and did a simple “rm -rf libtest“. And voilà. So, next time Windows forbids me from doing something, it might be a good idea to directly rely on a true terminal from a Unix-like environment. I didn’t try a liveCD (I didn’t have such CD to hand) but it might be also possible.

ForbidSleepingMode updated

Following some comments on the dependency to version 4 of the .Net framework, I rewrote ForbidSleepingMode in C++. You can open and compile the project with Qt (open source). The source code is of course updated. The mandatory screenshot as well 🙂

forbidSleepingMode screenshot

As you can see, I took the opportunity to add a small field where you can specify your own interval at which the program will “tickle” your computer.

forbidSleepingMode

I just put my first small tool on GitHub: forbidSleepingMode. It will forbid your (Windows) computer to enter into sleep mode, acting as if there was activity all the time. I’m sure you can think of 1001 productive uses for such tool.

Technically, it just sends a “tickle” to the computer every 10 minutes forcing the display to remain on (hence: don’t set your screensaver to come before 10 minutes). Build it with Visual Studio 10 (I know, I know …).

The mandatory screenshot (very, very useful):

forbidSleepingMode screenshotI intend to re-publish old tools on GitHub as I find them.

What is my proxy on Windows XP?

In computer networks, a proxy server is a server (a computer system or an application) that acts as an intermediary for requests from clients seeking resources from other servers.” From Wikipedia. This can be useful for a company to force its employees to use a proxy (to filter where they surf, to cache the web content for speed issues, to keep machines on the network anonymous, etc.). This post will look at 3 ways to get the proxy definition for a Windows XP machine in order to use that information in another program. It may work in other Windows-type operating systems.

The first one is to use the command line tool proxycfg but this is different from the one that may be used by Internet Explorer, see here. On my corporate PC, there is no proxy defined this way. But there is one defined in Internet Explorer.

So, in Internet Explorer, to see the proxy connection, you go in the “Tools” menu -> “Internet Options” -> “Connections” tab. And then click on the “LAN settings” button. But this can be blocked by your PC administrator (it’s my case) so let’s look at the other options.

Another option is to use the Firefox (if your company allows you to use it): in the “Tools” menu -> “Options” -> “Advanced” tab -> “Network” tab, in the box named “Connection”, click on the “Settings” button. Then:

  • You have no luck if the settings are auto-detected.
  • If the option “No proxy” is chosen, your company doesn’t use a proxy.
  • If the option “Use system proxy settings” is chosen, you should have seen the proxy with the command line tool proxycfg above.
  • If the option “Manual proxy configuration” is chosen, you can directly read the parameters.
  • If the option “Automatix proxy configuration URL” is chosen, you can copy-paste the link given in the text field in the address bar to see how Firefox will determine which proxy to use. This page is just a bit of code that tells Firefox in which conditions it should use what proxy. You can find some details here or elsewhere on the web. You have to use the value just after the string “PROXY“. For instance, your proxy is “LOCATIONPROXY01” if your proxy string is “PROXY LOCATIONPROXY01“. If there are many proxy definitions, you have to try to understand the logic behind the .pac file if you want to be sure to find the correct one. Or you can try all of them (brute-force) and you’ll find the one that works.

FluTE makefile for wxDev-C++ (Windows)

FluTE is an influenza epidemic simulation model written by Dennis L. Chao at CSQUID. It works out-of-the box on GNU/Linux (just type make and run it).

I wanted to see how it works. But since I’m temporarily stuck with a Windows laptop, I downloaded a free C++ compiler for Windows (wxDev-C++), imported all the files in a project and compiled. For those who want to try, here is the project file and the specific makefile in a zip file (2 kb). Just decompress the FluTE archive (I used version 1.15), copy the two files from the zip file above and launch the IDE. In the project options (Alt+P), specify the custom makefile (in the "Makefile" tab) as the one from the zip file above. Compile (Ctrl+F9). Done.

On my Intel Core2 Duo T5450 (2Gb RAM), it took 6 minutes to simulate the "two-dose" example.

Please note that I didn’t try to compile with OpenMPI. Maybe for next time.

Some useful software for programmers stuck on MS-Windows

Sometimes, even if you mainly develop on Unix/Linux boxes, you are stuck with MS-Windows on your desktop. Moreover, although your are a developer (i.e. someone who is supposed to know how to run a computer), you have no administrator rights so you can’t install the right tools that can improve your productivity and enhance your code stability/security. This is for the sad part.

Fortunately, Free Software are there and most of them can even be run without being installed on your machine, just copy the software and use it! Here is a list of some of the software I’m using. Feel free to promote your favourite application in the comments.

  • CamStudio: record video of bugs for support (free to use)
  • Virtual Desktop Manager: many desktops on MS-Windows (free to use)
  • doxygen: automatically generate documentation from your code (Free Software)
  • Eclipse: integrated development environment with support of many languages (including old COBOL!) and version control systems (Free Software)
  • FileZillaPortable: move file to/from servers (Free Software)
  • Firefox: test web application in a popular browser (Free Software)
  • freemind: mind mapping application (Free Software)
  • GIMPPortable: edit screenshots when you encounter a bug (Free Software)
  • htmlhelp: edit help files for end-users (free to use)
  • InkscapePortable: easily draw any scheme (Free Software)
  • j2sdk1.4: support old Java applications (free to use)
  • jdk1.6: develop and run new Java applications (free to use)
  • LaTeX (MiKTeX): write your dev reports (Free Software)
  • Lynx: surf fast without distraction (Free Software)
  • Netbeans: integrated development environment with support of version control systems (Free Software)
  • PuTTY: connect to servers in SSH (Free Software)
  • PuTTY connection manager: regroup PuTTY windows (Free Software)
  • SumatraPDF: free PDF reader (Free Software)
  • TeXnicCenter: LaTeX editor working with MiKTeX (Free Software)
  • tidy.exe: tidy your HTML code (Free Software)
  • todolist: simple todolist (Free Software)
  • TOra: Oracle database front-end (Free Software)
  • VLCPortable: listen to music and watch all movies (Free Software)
  • wget.exe: easily get files without a browser (Free Software)
  • xmlstarlet: check and process XML files (Free Software)

Firefox 3.0 + Flash on a protected Windows PC

Very often, your company doesn’t allow you to install a new software on your company computer. For this purpose, Portable Apps is a very interesting website: it contains a lot of free software ready to be used, without any installation process. Moreover, it releases latest version of software very quickly. For example, 1 or 2 days after the launch of Mozilla Firefox 3.0, it was already in Portable Apps.

Most Firefox plugins (“add-ons“) can be installed in the Portable apps version of Firefox, but not all of them. The Adobe Flash plugin is one of the few ones that you can’t install without administrator rights …

Unless your company installed Firefox 2.x on your computer with the Flash plug-in. If it’s the case, you have just to copy two files from the 2.x install to the 3.0 one :

Go to your “old” Firefox plugins directory, for example: C:\Program Files\Mozilla Firefox\plugins\. Then copy these 2 files: NPSWF32.dll and NPSWF32_FlashUtil.exe to your Portable Firefox directory, like: FirefoxPortable\App\firefox\plugins\. Now re-start Firefox 3.0 … Voilà!