0

I am runnig below script to check soft installedo n my computer - windows 7

wmic product get name,version >%date%softwarelist.txt

It works and i am able to see the soft and ver that are saved on file with current date

But when i try to do the same on winServ2012R2 i got info - > The system cannot find the path specified.

What cause it and how to fix it ?

Wiktor
  • 507
  • 7
  • 19
  • 1
    compare `%date%` on both systems. – Stephan Jan 23 '19 at 13:49
  • ok i see that on server i got '23' is not recognized as function and in win 7 i got '2019-01-23 is not recognized as function – Wiktor Jan 23 '19 at 13:59
  • 2
    you were supposed to execute `echo %date%` and compare them. The date format of your server contains characters that are not valid for filenames or spaces. You probably need to convert the date string. Show the output of `echo %date%` on your server and we can tell you, how. – Stephan Jan 23 '19 at 14:01
  • C:\Scripts>echo %date% 23/01/2019 – Wiktor Jan 23 '19 at 14:02
  • 3
    Alternatively you can / should use a [date string that doesn't depend on regional settings](https://stackoverflow.com/a/18024049/2152082). – Stephan Jan 23 '19 at 14:02
  • 1
    `... >%date:/=-%-softwarelist.txt` replaces the invalid `/` with valid `-`. – Stephan Jan 23 '19 at 14:03

1 Answers1

2

Here's a quick example:

@Echo Off
Set "MyDate="
For /F "EOL=L" %%A In ('WMIC OS Get LocalDateTime'
) Do Set "MyDate=%%~nA" & GoTo :Break
:Break
If Not Defined MyDate Exit /B
WMIC /Output:"%MyDate%SoftwareList.txt" Product Get Name,Version
Compo
  • 30,301
  • 4
  • 20
  • 32