Dr-NULL / CMD-Printer

A NPM module for print PDF in Windows
MIT License
3 stars 2 forks source link

windows7 can`t find printer #8

Open CloudWoR opened 3 years ago

CloudWoR commented 3 years ago

my project is a electoren program,
The EXE software compiled by the electron project can correctly obtain the printer list on Windows 10, but the printer list cannot be obtained in Windows 7. Why?

Dr-NULL commented 3 years ago

The package execute a powershell command to get the available printers. So, it was designed to run in Windows 10 and Windows Server 2019, althrough I don't tested in other SO.

I see 2 posibilities:

01.- Powershell Location

If you see this file at line 14, you will see a call to powershell (inside of C:\windows\system32), So you sould to check the content of your system32 folder, and search inside of this a powershell.exe executable file. If that file doesn't exists, try to install powershell in windows 7, and tell me if the executable file appears inside of system32 (for add an option to set a custom powershell path in a new version).

02.- Powershell version

If powershell.exe exists inside of system32 probably your version can't execute the command used to get all printers. Try to open powershell, and execute this command:

Get-Printer | Select-Object Name, ComputerName, Type, DriverName, PortName, Shared, ShareName, Published | ConvertTo-Json 

This command must returns a JSON with all printers installed in the system. If you get an error with this command, your powershell version it's oudated.

CloudWoR commented 3 years ago

Thank you very much. The problem of unable to obtain the printer has been solved, but the terminal failed to send a task to the printer during test printing. I'm trying to find out whether it's windows.

Dr-NULL commented 2 years ago

Are you checked the powershell version in your windows distribution? Give me your powershell version:

Check if this command works:

Get-Printer | Select-Object Name, ComputerName, Type, DriverName, PortName, Shared, ShareName, Published | ConvertTo-Json

If yout powershell version is 5.0 or upper, and the Get-Printer command works as expected, then the problem is allocated in the module's source code.