views:

172

answers:

3

I am looking for a way to pass a string containg the "*" character to an executable via the command line.

  command.exe 3*2

I want to pass the string 3*2. What Windows does instead is search the current directory for files matching the file mask "3*2", and passes any files it found to command.exe

Putting "3*2" between double quotes does not help, still the same problem.

I also tried '3*2' (between single quotes), but then this whole string (including the single quotes) is passed, which is not what I need.

Is there any way to pass the string 3*2 (without any quotes) to the command?

+1  A: 

In Windows command shells, the command you execute is responsible for expanding any wildcards present in the parameters. This behaviour is different to Unix and friends, where wildcard expansion is usually done by the shell.

A simple example demonstartes this.

Windows (Windows 7):

C:\Users\Frank>echo *
*

As you can see, the command outputs the parameter exactly as passed in by the command line.

Linux (bash on CentOS Linux 5):

> echo *
centos-release-5-0.0.el5.centos.2.i386.rpm centos-release-notes-5.0.0-2.i386.rpm glibc-2.5-12.i386.rpm glibc-common-2.5-12.i386.rpm virtualmin-install.log

Here the wild card parameter is substituted by the shell to a list of file/directories in the current directory.

So if your executable handles wildcard characters by expanding them, there is not much you can do about it. The concrete behaviour depends on your command.

If you provide more details about your command and what you want to achieve, we might be able to give some more help.

Frank Bollack
A: 
ephemient
A: 

you can try escaping

command.exe 3^*2
ghostdog74