Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Command-line wildcard arguments - not expanding


23 Feb 2012   #1

Windows 7 Home Premium (x64)
 
 
Command-line wildcard arguments - not expanding

Hello everyone:

Recently, I tried testing a small utility I wrote (in C). I found it wasn't behaving as expected when invoking the program from the command line. I have attempted to Google for more information regarding Windows 7 command-line wildcards, but haven't found anything specifically helpful to my case.

"Quick Edit mode" and "Insert mode" are enabled on my CMD shortcut.

The problem is that, when invoking my own programs, using wildcards to match multiple files results in the literal wildcard being passed as an argument instead of the expanded list. So, I wrote a small test program that simply echoes back the arguments passed, and here's what it looks like:
Code:
C:\Users\curtis\dev\xmv>cl /O2 /Wall args.c && rm *.obj
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

args.c
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:args.exe
args.obj

C:\Users\curtis\dev\xmv>dir
 Volume in drive C is OS
 Volume Serial Number is 3624-94BA

 Directory of C:\Users\curtis\dev\xmv

02/23/2012  12:08 AM    <DIR>          .
02/23/2012  12:08 AM    <DIR>          ..
02/23/2012  12:02 AM               171 args.c
02/23/2012  12:08 AM            39,936 args.exe
02/22/2012  10:12 PM    <DIR>          include
03/17/2007  04:16 AM             7,378 pcre.lib
03/17/2007  04:16 AM             3,250 pcreposix.lib
02/22/2012  08:42 PM               533 rename.c
02/22/2012  09:47 PM             2,938 replace.c
02/22/2012  09:47 PM             2,353 xmv.c
02/22/2012  09:47 PM            50,688 xmv.exe
               8 File(s)        107,247 bytes
               3 Dir(s)  422,124,756,992 bytes free

C:\Users\curtis\dev\xmv>args *.c
*.c

C:\Users\curtis\dev\xmv>
The strange thing is that the wildcard syntax operates correctly for native commands and batch scripts. However, as shown above, the invocation of the "args" program yields unexpected behavior.

Since batch scripts seem to echo out wildcard expansions correctly, I tried:
Code:
C:\Users\curtis\dev\xmv>type test.bat
@echo off

args %*


C:\Users\curtis\dev\xmv>test *.c
*.c
C:\Users\curtis\dev\xmv>
Unfortunately, the behavior is the same.

If I run the same "args" program in a Cygwin terminal, the wildcard operates as expected, even when invoking my own programs.

My System SpecsSystem Spec
.

Reply

 Command-line wildcard arguments - not expanding




Thread Tools



Similar help and support threads for2: Command-line wildcard arguments - not expanding
Thread Forum
UAC bug with runas from command line? General Discussion
How can I set this via command-line or registry? Customization
Gpedit via command line Performance & Maintenance
libraries and the command line Performance & Maintenance
How to run a command line utility? General Discussion
Command Line General Discussion
Can you boot from the command line? Chillout Room

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 05:18 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33