stop DOS truncating column output

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
confuseis
Posts: 11
Joined: 11 Dec 2011 09:59

stop DOS truncating column output

#1 Post by confuseis » 03 Jul 2016 07:18

Hi

I want to stop DOS truncating output.

In this case I am using the "driverquery" command to list all the drivers

The column "Display name" has been shortened in the output to about 22 characters

id like to run the driverquery comand but show the full output for all its columns

I searched but cant find how to do this

Thanks for reading

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: stop DOS truncating column output

#2 Post by foxidrive » 03 Jul 2016 07:59

Code: Select all

driverquery /fo csv
driverquery /fo list


Use driverquery /? for more info

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: stop DOS truncating column output

#3 Post by Compo » 03 Jul 2016 09:20

You need to indicate what you doing with the output, just looking at it or using it for something!

There is no way that you will be able to easily read that output data in a standard sized (or usual) console window.

My output is more than 250 rows and 120 characters wide!
Image

It may also be useful if you provided us with the target Operating System.

confuseis
Posts: 11
Joined: 11 Dec 2011 09:59

Re: stop DOS truncating column output

#4 Post by confuseis » 03 Jul 2016 15:10

I have tweaked the cmd.exe window size & buffer to comfortably fit the text into

I have tried every combination from the driverquery /? command

I see that the csv export does have the column headers with full info displayed however I require this in a text file
The export to text file has the columns squashed and it would not be inhibited by windows size etc.
The console output has the display njame column shortened also.

I need the output in a text file, the text file is for gathering diagnostic info from a machine
e.g. driverquery >> bleh.txt

Any way to tell cmd.exe not to do this in the output ?

The "display name" column is too short


Thanks

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: stop DOS truncating column output

#5 Post by Compo » 03 Jul 2016 15:30

Here's how I'd do it!

Code: Select all

@Powershell -ExecutionPolicy Bypass -C "DriverQuery.exe /FO CSV | ConvertFrom-CSV | Select-Object 'Module Name', 'Display Name', 'Driver Type', 'Link Date' | ft -Auto | Out-String -Width 4096 | Out-File output.log"
That's one single line.

Your output.log should contain what you need

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: stop DOS truncating column output

#6 Post by foxidrive » 04 Jul 2016 11:03

That works well here Compo.

Does this command work on machines that have never run powershell before, and so haven't been configured to run powershell scripts?

@Powershell -ExecutionPolicy Bypass

From appearance it would seem that it does.
I always thought that Powershell couldn't run on a machine which wasn't prepped in that way.

I've been wrong before though. I think the last time was in 1983 some time. ;)

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: stop DOS truncating column output

#7 Post by Compo » 04 Jul 2016 12:07

As you have already found out, yes it does.

It's not usually something I'd recommend but for those who tend not to use powershell, (read as batch community), I'd prefer them to leave their machine set to it's default of not running scripts and use this for the odd occasion when it may be necessary to use it.

@confuseis, if you've already set your window to the sizes required then you could obviously remove the last piped 'Out-File' section of the command to see it in your open console window.

confuseis
Posts: 11
Joined: 11 Dec 2011 09:59

Re: stop DOS truncating column output

#8 Post by confuseis » 04 Jul 2016 13:12

Yep Compo that powershell line works beautifully.

@Powershell -ExecutionPolicy Bypass -C "DriverQuery.exe /FO CSV | ConvertFrom-CSV | Select-Object 'Module Name', 'Display Name', 'Driver Type', 'Link Date' | ft -Auto | Out-String -Width 4096 | Out-File output.log"

Didnt know that trick, will be useful in future

Thats me sorted

Thanks all

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: stop DOS truncating column output

#9 Post by Aacini » 04 Jul 2016 13:29

Compo wrote:It's not usually something I'd recommend but for those who tend not to use powershell, (read as batch community), I'd prefer them to leave their machine set to it's default of not running scripts and use this for the odd occasion when it may be necessary to use it.


For such odd occasions I prefer to use this, simpler syntax:

Code: Select all

@Powershell DriverQuery.exe /FO CSV ^| ConvertFrom-CSV ^| Select-Object 'Module Name', 'Display Name', 'Driver Type', 'Link Date' ^| ft -Auto ^| Out-String -Width 4096 ^| Out-File output.log

Antonio

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: stop DOS truncating column output

#10 Post by Compo » 04 Jul 2016 13:45

Aacini wrote:

Code: Select all

@Powershell DriverQuery.exe /FO CSV ^| ConvertFrom-CSV ^| Select-Object 'Module Name', 'Display Name', 'Driver Type', 'Link Date' ^| ft -Auto ^| Out-String -Width 4096 ^| Out-File output.log

It appears to do exactly what we wanted and despite the fact I have a Restricted ExecutionPolicy on this machine!

Whilst I'm here, I remembered Mr Benham once posting a solution to the change of window buffer width & height and thought I'd offer this as an alternative to view it in the window without pre-configuring the console.

Code: Select all

@Set/A W=130, H=260
@Powershell -C "&{$H=get-host;$R=$H.ui.rawui;$B=$R.buffersize;$W=$R.windowsize;$B.width=if (%W% -gt $W.width) {%W%} else {$W.width};$B.height=if (%H% -gt $W.height) {%H%} else {$W.height};$R.buffersize=$B};DriverQuery.exe /FO CSV | ConvertFrom-CSV | Select-Object 'Module Name', 'Display Name', 'Driver Type', 'Link Date' | ft -Auto"
@Timeout -1
It maintains the window width and height, but alters the buffer, (set on line one), accordingly, allowing me to scroll and read.

Post Reply