Technology Tales

Adventures & experiences in contemporary technology

Shell swapping in Windows

28th April 2010

Until the advent of PowerShell, Windows had been the poor relation when it came to working from the command line when compared with UNIX, Linux and so on. A recent bit of fiddling had me trying to run FTP from the legacy command prompt when I ran into problems with UNC address resolution (it’s unsupported by the old technology) and mapping of network drives. It turned out that my error 85 was being caused by an unavailable drive letter that the net use command didn’t reveal as being in use. Reassuringly, this wasn’t a Vista issue that I couldn’t circumvent.

During this spot of debugging, I tried running batch files in PowerShell and discovered that you cannot run them there like you would from the old command prompt. In fact, you need a line like the following:

cmd /c script.bat

In other words, you have to call cmd.exe like perl.exe, wscript.exe and cscript.exe for batch files to execute. If I had time, I might have got to exploring the use ps1 files for setting up PowerShell commandlets but that is something that needs to wait until another time. What I discovered though is that UNC addressing can be used with PowerShell without the need for drive letter mappings, not a bad development at all. While on the subject of discoveries, I discovered that the following command opens up a command prompt shell from PowerShell without any need to resort to the Start Menu:

cmd /k

Entering the exit command returns you to the PowerShell command line again and entering cmd /? reveals the available options for the command so you need never be constrained by your own knowledge or its limitations.

Some things that I’d miss on moving from Linux to Windows

17th January 2009

The latest buzz surrounding Windows 7 has caused one observer to suggest that it’s about to blast Linux from the desktop. My experiences might be positive but there are still things that I like about Linux that make me reluctant to consider switching back. Here are a few in no particular order:

Virtual Desktops (or Workspaces)

I find these very handy for keeping things organised when I have a few applications open at the same time. While I think that someone has come with a way of adding the same functionality to Windows but I’d need to go looking for that. Having everything cluttering up a single taskbar would feel a bit limiting.

Symbolic Links

If you have come across these before, they are a little hard to explain but it’s great to have to have the ability to make the contents of a folder appear in more than one place at a time without filling up your hard drive. It’s true to say that Windows 7 gets Libraries but I have a soft spot for the way that Linux does it so simply.

Lack of (intrusive) fidgeting

One of Windows’ biggest problems is that it’s such a massive target for attacks by the less desirable elements of the web community. The result is a multitude of security software vendors wanting to get their wares onto your PC and it’s when they get there that all of the fidgeting starts. The cause is the constant need for system monitoring and it eats up resources that could be used for other things. I know some packages are less intrusive than others but I do like the idea of feeling as if I am in full control of my PC rather someone else taking decisions for me (unavoidable in the world of work, I know). An example of this is Norton’s not allowing me to shut it down when it goes rogue, even when acting as Administrator. I can see the reason for this in that it’s trying to hamper the attentions of nefarious malware but it ends up making me feel less than empowered and I also like to feel trusted too. Another thing that I like is the idea of something awaiting my input rather going away and trying to guess what I need and getting it wrong, an experience that seems typical of Microsoft software.

Command Line

This is less of a miss than it used to be but there is now a learning curve with PowerShell’s inclusion with Windows 7 and it’s not something that I want to foist on myself without my having the time learning its ins and outs. It’s not a bad skill to have listed on the proverbial CV but I now know my way around bash and its ilk while knowing where to look when I want to take things further.

After these, there are other personal reasons for my sticking with Linux like memories of bad experiences with Windows XP and the way that Linux just seems to get on with the job. Its being free of charge is another bonus and the freedom to have things as you want makes you feel that you have a safer haven in this ever changing digital world. I am not sure if I’d go acquiring the final version of Windows 7 but I am certain that it will not be replacing Linux as my main home computing platform, something that come as no surprise given what I have said above.

Running Windows 7 within VirtualBox

12th January 2009

With all the fanfare that surrounded the public beta release of Windows 7, I suppose that the opportunity to give it a whirl was too good to miss. Admittedly, Microsoft bodged the roll-out by underestimating the level of interest and corralling everyone into a 24 hour time slot with one exacerbating the other. In the event, they did eventually get their act together and even removed the 2.5 million licence limit. I suppose that they really need to get 7 right after the unloved offering that was Vista so they probably worked out that the more testers that they get, the better. After, it might be observed that the cynical view that the era making people pay to “test” your products might be behind us and that users just want things to work well if not entirely faultlessly these days.

After several abortive raids, I eventually managed to snag myself a licence and started downloading the behemoth using the supplied download manager. I foresaw it taking a long time and so stuck with the 32-bit variant so as not to leave open the possibility of that part of the process using up any more of my time. As it happened, the download did take quite a few hours to complete but this part of the process was without any incident or fuss.

Once the DVD image was downloaded, it was onto the familiar process of building myself a VirtualBox VM as a sandbox to explore the forthcoming incarnation of Windows. After setting up the ISO file as a virtual DVD, installation itself was an uneventful process but subsequent activities weren’t without their blemishes. The biggest hurdle to be overcome was to get the virtual network adapter set up and recognised by Windows 7. The trick is to update the driver using the VirtualBox virtual CD as the source because Windows 7 will not recognise it using its own driver repository. Installing the other VirtualBox tools is a matter of going to Compatibility page in the Properties for the relevant executable, the one with x86 in the file name in my case, and setting XP as the Windows version (Vista works just as well apparently but I played safe and depended on my own experience). While I was at it, I allowed the file to run under the administrator account too. Right-clicking on executable files will bring you to the compatibility troubleshooter that achieves much the same ends but by a different route. With the Tools installed, all was workable rather than completely satisfactory. Shared folders have not worked for but that might need a new version of the VirtualBox software or getting to know any changes to networking that come with Windows 7. I plan to stick with using USB drives for file transfer for the moment. Stretching the screen to fit the VirtualBox window was another thing that would not happen but that’s a much more minor irritation.

With those matters out of the way, I added security software from the list offered by Windows with AVG, Norton and Kaspersky being the options on offer. I initially chose the last of these but changed my mind after seeing the screen becoming so corrupted as to make it unusable. That set me to rebuilding the VM and choosing Norton 360 after the second Windows installation had finished. That is working much better and I plan to continue my tinkering beyond this. I have noticed the inclusion of PowerShell and an IDE for the same so that could be something that beckons. All in all, there is a certain solidity about Windows 7 but I am not so convinced of the claim of speedy startups at this stage. Time will tell and, being a beta release, it’s bound to be full of debugging code that will not make it into the final version that is unleashed on the wider public.

Automating FTP II: Windows

15th April 2008

Having thought about automating command line FTP on UNIX/Linux, the same idea came to me for Windows too and you can achieve much the same results, even if the way of getting there is slightly different. The first route to consider is running a script file with the ftp command at the command prompt (you may need %windir%system32ftp.exe to call the right FTP program in some cases):

ftp -s:script.txt

The contents of script are something like the following:

open ftp.server.host
user
password
lcd destination_directory
cd source_directory
prompt
get filename
bye

It doesn’t take much to turn your script into a batch file that takes the user name as its first input and your password as its second for sake of enhanced security and deletes any record thereof for the same reason:

echo open ftp.server.host >  script.txt
echo %1 >> script.txt
echo %2 >> script.txt
echo cd htdocs >> script.txt
echo prompt >> script.txt
echo mget * >> script.txt
echo bye >> script.txt
%windir%system32ftp.exe -s:script.txt
del script.txt

The feel of the Windows command line (in Windows 2000, it feels very primitive but Windows XP is better and there’s PowerShell now too) can leave a lot to be desired by someone accustomed to its UNIX/Linux counterpart but there’s still a lot of tweaking that you can do to the above, given a bit of knowledge of the Windows batch scripting language. Any escape from a total dependence on pointing and clicking can only be an advance.

Filename autocompletion on the command line

19th October 2007

The Windows 2000 command line feels an austere primitive when compared with the wonders of the UNIX/Linux equivalent. Windows XP feels a little better and PowerShell is another animal altogether. With the latter pair, you do get file or folder autocompletion upon hitting the TAB key. What I didn’t realise until recently was that continued tabbed cycled through the possibilities; I was hitting it once and retyping when I got the wrong folder or file. I stand corrected. With the shell in Linux/UNIX, you can get a listing of possibilities when you hit TAB for the second time and the first time only gives you completion as far as it can go with certainty; you’ll never get to the wrong place but you may not get anywhere at all. This works for bash but not ksh88 as far as I can see. It’s interesting how you can take two different approaches in order to reach the same end.

Windows Powershell

1st March 2007

The Windows command has always been the poor relation of its UNIX equivalent and it seems that Microsoft released PowerShell in order to remedy this. It seems to offer scripting possibilities beyond what is already available in Windows and is a free download for XP and Vista. I haven’t got to exploring its potential yet but it is on the to do list.

  • All the views that you find expressed on here in postings and articles are mine alone and not those of any organisation with which I have any association, through work or otherwise. As regards editorial policy, whatever appears here is entirely of my own choice and not that of any other person or organisation.

  • Please note that everything you find here is copyrighted material. The content may be available to read without charge and without advertising but it is not to be reproduced without attribution. As it happens, a number of the images are sourced from stock libraries like iStockPhoto so they certainly are not for abstraction.

  • With regards to any comments left on the site, I expect them to be civil in tone of voice and reserve the right to reject any that are either inappropriate or irrelevant. Comment review is subject to automated processing as well as manual inspection but whatever is said is the sole responsibility of the individual contributor.