Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make the columns in VBscript fixed
    text
    copied!<p>I'm a beginner in VBscript and I got a script which obtains disk space usage of local drives. However, when some columns would contain long numeric value, some adjacent columns and even values are moving to the right and thus makes the output disorganized. I already </p> <p>Please see below the contents of the script:</p> <pre><code>Option Explicit const strComputer = "." const strReport = "F:\dba_scripts\diskspace.txt" Dim objWMIService, objItem, colItems Dim strDriveType, strDiskSize, txt Set objWMIService = GetObject("winmgmts:\\" &amp; strComputer &amp; "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk WHERE DriveType=3") txt = "DRIVE" &amp; vbtab &amp; vbtab &amp; "SIZE" &amp; vbtab &amp; vbtab &amp; "USED" &amp; vbtab &amp; vbtab &amp; "FREE" &amp; vbtab &amp; vbtab &amp; "FREE(%)" &amp; vbcrlf For Each objItem in colItems DIM pctFreeSpace,strFreeSpace,strusedSpace pctFreeSpace = INT((objItem.FreeSpace / objItem.Size) * 1000)/10 strDiskSize = round((objItem.Size /1073741824),1) &amp; " GB" strFreeSpace = round((objItem.FreeSpace /1073741824),1) &amp; " GB" strUsedSpace = round(((objItem.Size-objItem.FreeSpace)/1073741824),1) &amp; " GB" txt = txt &amp; objItem.Name &amp; vbtab &amp; vbtab &amp; strDiskSize &amp; vbtab &amp; vbtab &amp; strUsedSpace &amp; vbTab &amp; vbtab &amp; strFreeSpace &amp; vbtab &amp; vbtab &amp; pctFreeSpace &amp; vbcrlf Next writeTextFile txt,strReport wscript.echo "Report written to " &amp; strReport &amp; vbcrlf &amp; vbcrlf &amp; txt ' Procedure to write output to a text file private sub writeTextFile(byval txt,byval strTextFilePath) Dim objFSO,objTextFile set objFSO = createobject("Scripting.FileSystemObject") set objTextFile = objFSO.CreateTextFile(strTextFilePath) objTextFile.Write(txt) objTextFile.Close SET objTextFile = nothing end sub </code></pre> <p>The output file looks OK but when I send/email it using the free bmail, the results are disorganized (meaning some columns and values moved to the right. </p> <p>My question is are there ways to make the columns and values results fixed ( meaning no columns and values are moving to the right )?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload