[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

batch file: open file with wild cards

I have a situation where I need users to open a file via a batch script
ie:
start c:\special\A6_flast.doc

As you can gather, the file is located in "c:\special" on each users PC, the problem is that while the file they need to open starts with "A6_" it's appended with their first letter of their name and full last name, ie: A6_mbolton.doc or A6_snayeenanajar.doc

How can I launch this file with a batch script? (which I intend to email the users)

this:
  start c:\special\A6_*.doc
won't work

Unfortunately, mbolton and snayeenanajar are not valid network user names, so I can't use the %username% environmental variable in the batch file
0
Marketing_Insists
Asked:
Marketing_Insists
1 Solution
 
jmacmickingCommented:
If it's the only file in the folder you can use the FOR statement:

FOR %%c IN ("C:\Special\*.doc") DO START %%c
0
 
Marketing_InsistsAuthor Commented:

  FOR %%c IN ("C:\Special\A6_*.doc") DO START %%c

works perfect, thanks
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now