0

How can I make a command string work using globing patterns also in the given arguments?

powershell.exe -c "&'c:\wind?ws\System32\more.com' C:\path\to\something.txt | findstr 'something'" -> this works

This is what I would like to do, for example:

powershell.exe -c "&'c:\wind?ws\System32\more.com' C:\wind?ws\w?n.ini | findstr 'something'"

I tried using another &, but seems like is gets interpreted in the wrong way

jagghy
  • 3
  • 1

1 Answers1

0

In cmd, you can use global wildcards like * and ? in the last element of a path only.

Here are (some) equivalent alternatives:

  • if you insist upon more.com and findstr.exe:
powershell.exe -nopro -c "& 'c:\wind?ws\Syst?m32\mor?.com' (Resolve-Path C:\wind?ws\w?n.ini) | findstr 'fil ext app'"
; for 16-bit app support
[extensions]
[mci extensions]
[files]
  • use native PowerShell instruments:
powershell.exe -nopro -c "(Get-Content C:\wind?ws\w?n.ini) -match 'fil|ext|app'"
; for 16-bit app support
[extensions]
[mci extensions]
[files]
JosefZ
  • 1,564
  • 1
  • 10
  • 18