Tim Evans Windows Tips

Tim Evans Computing Tips Home Page | Tim Evans Informal Home Page | Tim Evans Imperial College page

Some Recommended Programs for Microsoft Windows

This is a list of some of the programmes I find useful under Windows

Installing LaTeX on Windows

These are my recommendations for installing LaTeX. See Tim Evans' tips on the use of LaTeX for bits and pieces on how to use LaTeX independent of the operating system you use.

It helps to know if you have 32 or 64 bit windows. It tells you this under control panel -> system where mine says System Type: 64 bit Operating system. If in doubt 32 bit versions should always work.

Next download the programmes you need. In each case google (programme name) download should find the page you need. I suggest you do this in the following order but it may not be essential. In each case the installation these days is relatively simple. If the files names have a 32 or 64 in them this indicates which version of Windows it is for. If you want to live without postscript (I tend to use pdf nowerdays) then the first two programmes are not needed. Personally I still find I use postscript from time to time (for figures in particular) so you may as well get them.

  1. Download ghostscript

    Look for Microsoft Windows self-extracting EXE. Choose 32 or 64 bit version as needed. Run file.

  2. Download ghostview

    Look for Microsoft Windows self-extracting EXE. Choose 32 or 64 bit version as needed. Run file.

  3. Download MiKTeX

    I suggest you use the MiKTeX Net Installer and follow the instructions on the web page linked near the net installer. Note this can be extremely slow (about one hour) to install. The actual download is large but its relatively quick these days. Most of the installation time is spent creating fonts and stuff. You will also then find the first few times you run LaTeX it may well go off and install extra packages or construct more fonts. I would not use the 64 bit option while it is experimental.

  4. Download WinEdt

    Installs simply. The licence for an individual is such a small part of the cost of your computer I would pay this and its not very useable if you do not. was well worth it. More comments on WinEdt are above.


Some Windows Tricks

To Copy the Screen or a Window on the Screen

On Windows to get a copy of the screen press alt+Print Screen key. Pressing cntrl+alt+Print Screen gives the active Window.

Windows 7 User Account Pictures

The image is upto 128 x 128 pixels in sizeor it will be resized, and allowed formats are .bmp, .dip, .rle, .gif, .jpg, or .png. The default pictures are hidden and are as follows:

Remote Login

Use mstsc (MS terminal services client) to connect to a Windows XP machine remotely from another MS Windows machine. In the run box type mstsc. From a Linux box try using rdesktop to access the terminal services. An alternative is to install VNC at both ends.

Windows run box

This is a quick and easy way to start many features of MS Windows. To get it up type windows key + r (using the special windows key on many keyboards) or go via the start button: start -> run.
For instance to get a command window up type cmd in the run box. Typing in the name of a programme known to Windows, e.g. excel, will also work in the run box. Typing in the name of the computer and its drive will give access to that network drive.

Task Scheduling

To find this, click on the start button then type task into the run box.

PDF on Windows

A good way to produce pdf files from any Windows application is to use the PrimoPDF converter which is free for single person use (company offers more solutions for developers, servers, etc). It appears as a printer so should work from most applications and it does not appear to change the appearance. Remember to change the paper size to A4 under the advanced settings of the printer properties. There is also a PrimoPDF online version you can use from a web site. An alternative is PDF4free but this adds a line with its name to each pdf page.

Built in disk partitioning software in Windows XP

Look for Disk Management under Computer Management. Can be found as the manage option when you right click My Computer or is in the control panel. Primitive but a good start.

Windows Command Line Tricks

Command Line Window

This is the inheritor of the old DOS window and it has many powerful commands. Try help commandname for information. Examples include

Batch Files

A useful resource is the Microsoft Batch File documentation. Remember that variable names on the command line are %A but are %%A in a batch file. Changes examp.es below as needed.

Files ending in .bat are run as batch files.

To run a batch file from another batch file and to continue to the next line even when the called bacth file has finished, use call

call batchfile.bat arg1 arg2

To search through files use the following (here the batch file compdir is called with an argument)

for /f %%f in (walkn*) do compdir %%f

To search through directories in a batch file use the following (here the batch file compdir is called with an argument)

for /d %%f in (walkn*) do compdir %%f

You can use these commands on the command line but must change the variable names. For example

for %f in (*.txt) do copy %f %~nf.dat
will rename all *.txt files in the current directory to have dat extensions.

You can extract various information from a file name. Consider the example above

for /f %%f in (walkn*) do compdir %%f
In the compdir batch file you can extract the following from the first argument %1 as follows:-
  1. %~d1 gives the drive
  2. %~p1 gives the path
  3. %~n1 gives the file name (no extension)
  4. %~x1 gives the file name (no extension)
You can combine these as in %~dpn1 so
for /R %f in (*.txt) do echo %~pnf
will give full path name except for the drive and extension.

This full list of expressions came from Batch: Remove file extension page on stackoverflow.

Variable with modifier  Description

%~I                     Expands %I which removes any surrounding
                        quotation marks ("").
%~fI                    Expands %I to a fully qualified path name.
%~dI                    Expands %I to a drive letter only.
%~pI                    Expands %I to a path only.
%~nI                    Expands %I to a file name only.
%~xI                    Expands %I to a file extension only.
%~sI                    Expands path to contain short names only.
%~aI                    Expands %I to the file attributes of file.
%~tI                    Expands %I to the date and time of file.
%~zI                    Expands %I to the size of file.
%~$PATH:I               Searches the directories listed in the PATH environment
                        variable and expands %I to the fully qualified name of
                        the first one found. If the environment variable name is
                        not defined or the file is not found by the search,
                        this modifier expands to the empty string.

Batch file to set Environment Variables

This illustrates the use of if statements, labels, and environment variables.
@echo off
@echo Setting General Environment Variables
set TODAY=%date:~-4,4%%date:~-7,2%%date:~0,2%
@echo Computer is %COMPUTERNAME% today is %TODAY%

if "%COMPUTERNAME%"=="PH-TIME-PC" goto phtimepc

:labelunknown
@echo *** Computer %COMPUTERNAME% is unknown in setenv.bat

:labelstd
@echo Standard Default Values Being Used
set CMDZIP=c:\PROGRA~1\winzip\wzzip
set DOCDIR=c:\DOC
set path=%path%;C:\Program Files\Java\jre1.6.0_03\bin
goto labelend

:phtimepc
@echo Values for PH-TIME-PC being Used
set CMDZIP=%ProgramFiles(X86)%\winzip\wzzip
set DOCDIR=%USERPROFILE%\Documents
set path=%path%;C:\Program Files\Java\jre1.6.0_03\bin
goto labelend

:labelend
set GPBKDIR=%DOCDIR%\RESEARCH\gpbk
set UNIBKDIR=%DOCDIR%\TEACHING\pg\UNI\unibk
@echo Finished setting General Environment Variables

Searching for files

The fastest way is to use the command line window and then to use the dir directory command
dir c:\doc\file*.txt /s
finds all the file*.txt files in the c:\doc directory and its subdirectories (the /s switch makes it look in all the subdirectories). Type help dir for more options.

Deleting all files and subdirectories of a directory

Use the rmdir (or its abbreviation rm with the /S parameter. It will prompt you before doing this but obviously use with extreme caution. For instance to remove directory C:\temp and all the subdirectories and files within it type
rmdir c:\temp /s

Changing read only status of file and directories

There appears to be a feature that means that you can't change the read-only status of files and directories using their properties box. The properties box doesn't even seem to reflect this setting. See this Microsoft Support page for more information. This attribute causes problems with some applications e.g.\ Netbeans. Use the attrib command from the command line. I use the following from a command line to remove the read-only tag from all the files and directories from the current location and recursively within that location
attrib -r *.* /s /d

Redirection of Output and Errors

Many programmes, including java ones, have two standard places they put messages, one for standard output and one for errors. Usually these are the command window or similar. If you want to redirect one or other of them to files use a command like
programme.bat SomeParameters  > StandardOutput.txt 2> StandardError.txt
See the Windows product documentation for information on this, found via google.

Environment Variables on Windows

Go to My Computer - Properties - Advanced - Environment Variables. Then add the required environment variable as required. For instance see the GIMP example below.

Use the set to set environment variables or to list them in a command window.

In a batch file surround the environment variable name by percentage signs to use. Sometimes quotes are needed. For examples see:-

Setting today's Time and Date

To set an environment variable with today's date and time try
set TODAY=%date:~-4,4%%date:~-7,2%%date:~0,2%

Show name of computer

@echo Computer is %COMPUTERNAME% 

robocopy command

The robocopy is a robust and flexible command for copying files. It allows recursion and lots of switches to choose types of fie, e.g. moving or copying, not copying older files, etc. There are several technical points and the /b /r:1 /w:1 /fft /xj switches were recommended in an article in Computer Shopper (UK magazine), November 2012. For instance to create a copy of all the tex files on one project in a Google Drive I use
robocopy %DOCDIR%\RESEARCH\gpbk\ "%USERPROFILE%\gpbk\Google Drive"  gpbk*.tex gpbk*.bat  /r:1 /w:1 /fft /xj /xo
Here DOCDIR is an enviornment variable defined by me, USERPROFILE is a system defined environment variable, note the quotes because of the space in teh directory name Google Drive and I failed to get the /b switch to work.

Programming under Windows

Compiling and Running Code On Windows

Some code is easily portable, e.g. java, once you've dealt with directory path issues. I use this and the cross platform, open source and free Netbeans IDE as my preferred combination.

For C and C++ I still find the Microsoft Visual Studio too complex. I have found compatibility issues (STL library?) when moving the code to Linux platforms in the past. It is also not a cross platform IDE though there is a free cut down version. So I use the Gnu Compiler collection and GCC for this. To install on Windows has been tricky though I hope it is better - see below.

For FORTRAN the GNU route that produces GCC provides a free compiler. You can usually get it installed at the same time as GCC. Also heavily recommended on the web (but I have not tried it), cheap if not free after 30 days, is the SimplyFortran package which includes an IDE and is based on the same GNU Fortran compiler recommended below. This cuts out all the complications of using Netbeans seen below if you just want Fortran.

Gnu compilers on Windows

The key is to look at Getting Started on the MinGW Wiki.

To test, try hand linking and compiling the simple Fortran code below. First find out where to put the code which is in the C:\MinGW\msys\1.0\home\USER directory where USER is your Windows user name. In that directory I put the simple Fortran code

       PROGRAM FTEST
************************************************************************
* This is a trivial programme                                          *
************************************************************************
       REAL RVAR
       RVAR = -9.807
       PRINT *, ' This is -9.807 ', RVAR
       END
To produce an executable I used
gfortran -c -g -o ftest.o ftest.f
gfortran -o ftest ftest.o
which produced an ftest.exe file but I'm sure if I read the manual I could decode the meaning of the flags. Type ftest and you should see the programme execute and produce output.

Netbeans and Gnu compilers on Windows

I use Netbeans along with ports to Windows of standard GNU compilers associated with MinGW (Minimalist GNU for Windows). It seems to be was very sensitive to the version of Netbeans being used. Start with the Netbeans trail on Configuring the NetBeans IDE for C/C++/Fortran but supplement this with the Netbeans Wiki pages and pages found googling terms like netbeans C++ MinGW. The instructions for both Cygwin and MinGW are useful for both installations as similar problems (paths etc) occur.

I found that my installation of MinGW (Gnu compilers versions 4.6.1) above worked fine with Netbeans 6.9 provided I altered the paths.

Initially I had a solution that (mostly) works with Netbeans 6.7.1 using MinGW, the make utility MSYS and the gnu debugger gdb. Note that the make utility is not the default one in MinGW so read the instructions on the Netbeans C++ page carefully. The HOWTO Install the MinGW (GCC) Compiler Suite is very useful as are the MinGW and MSYS installation instructions on Martin Rosvall's page.instructions . However I still found the installation did not work properly without more work. I looked in the installation to see where the executables were, e.g. search for gcc.exe. I found them in C:\MinGW\bin. I checked this was in the Windows PATH (system -> advanced settings) environment variable. Harder is finding some of the standard libraries such as the STL, which I found using dir c:\cygwin\vector /s. I found the directories were in C:\MinGW\include\c++\3.4.5. I made sure that these library directories were both in the Netbeans project settings (right click project then select properties) and in the tools - options - c++ - code assistance of Netbeans. Note that there may be separate entries for debug and release modes.

You can also try to get Netbeans working with Cygwin. In the case of Netbeans using the g++ compiler from Cygwin, I found that the paths were not set correctly for the STL of C++. Using dir c:\cygwin\vector /s I found the directories where the STL library files were. I added these to the PATH (system -> advanced settings) as

c:\cygwin\bin;c:\cygwin\lib\gcc\i686-pc-cygwin\3.3.4;C:\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include\c++;
and made sure that the directories also appeared both in the project settings and the tools-options-c++-code assistance of Netbeans. However this seemed to fail for me and I never got this working.

Note that I find that when creating a new C++ project, I need to create the directory first. Netbeans doesn't seem to do this for you complaining that its read only. This can also be due to the problems with read-only flags in Windows, use the attrib command to change them from the command line.


Older Information

Hopefully not needed anymore

Setting up HP printers on Windows

The detailed location may vary depending on if you use the Windows supplied driver or the one from the HP web site. I prefer the latter as it tends to have more features.

Note that there are two sets of these settings in two different places. One sets up the defaults, one are the values the PC is currently using. The point is the default values are the ones that people will see when they use the printer from their own computer. Thus one can set up three different printers (different queues) all using the same physical printer and even the same drivers underneath but they can have different default settings, e.g. one for economy, one for double sided and one for single sided printing.

Finally note that you will have to change some of the other settings.

Under the printer properties choose the following:- Device Settings Tab

Advanced Printing Defaults -> Advanced -> A4 paper General Printing Options -> Advanced -> A4 paper

Setting up printer queues on a Windows box for MAC and Linux machines

On Windows server and XP one can add UNIX print services, and on Windows Server 2003 one can also add MAC print services and MAC file services. Go to the control panel, add/remove programmes and then add/ remove Windows components. Highlight Other Network File and Print Services, click on the details button and select what you need. The installation CD is needed.

Once installed you need to check the printers can see the server, that the postscript used by modern MACS and Linux boxes is coming through and that the double/single sided options work. You may need to set up postscript driver queues on the server in which case remember to set the paper size and duplex options on in the drivers.

In the following we will assume that the Windows server is winprint, full IP address winprint.tp.ph.ic.ac.uk. In these examples we will attach it to the HP Laserjet 4250 printer on level 6 which has the printer name under Windows (the queue name) hp4250ps . Note that there are other queues but I recommend that on Linux and MACs that you use the postscript queues, those printer queues ending in ps. You may or may not find that the other queues work (they are set up for PCL). The main printer on level 5 is HP Laserjet 4100 (it is not an MFP - multifunction printer) and the queue you need is hp4100ps . It is listed on the same sever winprint. Note that Macs and Linux machines are using similar systems. However the details of how to access these different settings vary from version to version. Look at the different suggestions below as any one may help a Mac or Linux user. The UNIX print services sets up an lpd queue with the same names as Windows shares. In Linux (a live CD version of UBUNTU 7) I found this as follows:- System -> Printer Config -> New Printer Then either type in

lpd://winprint.dept.univ.ac.uk/hp4250ps
or choose type lpd and point it to the server winprint.dept.univ.ac.uk and then the queue required, e.g. hp4250ps You may have to go into the printer settings and make sure these know it has a duplex unit attached. On a MAC to use the lpd queue try the following:- Many systems can see the Windows printers under the smb system that Windows uses. In Linux (a live CD version of UBUNTU 7) I found this as follows:- System -> Printer Config -> New Printer Then I selected Windows Printer via SAMBA. If your printers are on different subnests there may be problems seeing printers this way.

For MACs they should be able to work via Appletalk. A trick on modern Macs is to hold down the Option key e.g. while clicking the Add button (in the Printer List window). You get many more advanced options.

A useful command on UNIX is lpstat -u which gives a list of printers.

Setting up Windows print queues to manipulate postscript

First of all, set up a normal printer queue for PostScript, using a PostScript printer driver. This will produce a double-sided queue, if the printer supports duplexing. (!!! So far having problems with the HP4250- any solutions?)
Next, install RedMon. Through RedMon one creates dummy queues which receive data and then send them on to another program instead of the printer. To install and configure RedMon, read the manual. Unfortunately RedMon does not work on Windows Server 2003 and does not seem to be updated.
To set up econ and single-sided (sside) queues, use the utility pstops (PS To PS). It comes with miktex, and can be found somewhere like
root\miktex\bin\

To set up an econ queue, create a redirected port with RedMon. Go to the properties of the queue, ports tab. Switch off Bidirectional Support. Under Redirect this port to program, put pstops. Under Arguments for the program put:
4:0L@.7(21cm,0)+1L@.7(21cm,14.85cm),2R@.7(0,29.7cm)+3R@.7(0,14.85cm)
Under output, choose copy stdout to printer. And choose the normal double sided queue for printer. Run as whatever, I suppose hidden is best.
For sside printing, do the same, apart from the arguments to the program pstops should be:
1:0
,

Setting up Windows postscript queues

Does this help? "Choose LPR instead of RAW and until LPR settings type PASSTHRU.". Can find some of these settings under PORTS - configure part of the Windows driver but for hp4100 and fs3830 printers printer RAW seems to be used