Reputation: 51
I need to pass a file name which can have the two first characters designating the year (??_zfgli1121 the file exists with the name "20_zfgli1121" ) as an argument to a vbscript. I receive an error executing, can you please help?
@ECHO OFF
Set SDir=D:\Data
Set InFile=%SDir%\??_zfgli1121
IF Exist %InFile% (
C:\Windows\SysWOW64\cscript %SDir%\Convert_SAP_Data.vbs %InFile%
)
Upvotes: 1
Views: 163
Reputation: 807
Some programs can handle asterisks and interrogations, others not.
An example of programs that they can't are CertUtil, CScript, WScript, Tree, and some others. Instead, you could do
for %%A in (%SDir%\??_zfgli1121) do set InFile=%%A
and then
C:\Windows\SysWOW64\cscript %SDir%\Convert_SAP_Data.vbs %InFile%
Tip:
Use the environment variables instead of fixed paths.
C:\Windows
→ %SystemRoot%
. To view them take a look at SET
Upvotes: 1