batch file - How to include hostname and date in output filename? -


i have batch file gets installed software , updates. looks this:

call wmic /output:"servername-installedsoftware-mmddyyyy.csv" qfe /format:csv 

every time run server, have modify batch file current server , date.

is there way can convert vbscript file grabs %computername% variable , mmddyyyy date values automatically?

from memory, echos mmddyyy part (in separate lines)

echo %date:~4,2% echo %date:~7,2% echo %date:~-4% 

and give servername:

echo %computername% 

so command should be

call wmic /output:"%computername%-installedsoftware-%date:~4,2%%date:~7,2%%date:~-4%.csv" qfe /format:csv 

you can try out substituting echo call wmic /output:

echo "%computername%-installedsoftware-%date:~4,2%%date:~7,2%%date:~-4%.csv" 

Comments