[Tex/LaTex] How to preserve tabs and whitespaces in \parbox in latex

boxeslistingsspacing

I am currently trying to insert a batch file programming code in my report. I am using the code listing. I am not able to preserve white spaces and tabs to format my code! I tried using \hspace but it didn't worked. I have following code example yet:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{listings}

    \begin{document}

    \begin{lstlisting}[escapechar=ä]
     ä\colorbox{white}{%
      \parbox{3.9in}{\color{black}\texttt{Microsoft Windows [Version 6.2.9200]\\\\
       (c) 2012 Microsoft Corporation. All rights reserved.}}}ä
    \end{lstlisting}

    \end{document} 

The output is like this which I don't prefer:

Microsoft Windows [Version 6.2.9200]

(c) 2012 Microsoft Corporation. All rights reserved.

I prefer a tab or white space before the second line starts. The output I prefer is as below:

Microsoft Windows [Version 6.2.9200]

      (c) 2012 Microsoft Corporation. All rights reserved.

Thanks.

Best Answer

You can easily set the style of a listings to blue typewriter text by using \lstset{basicstyle=\ttfamily\color{blue}}. As lstlisting is a verbatim environment, all spaces are preserved.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{listings}
\lstset{basicstyle=\ttfamily\color{blue}}
\begin{document}

\begin{lstlisting}
Microsoft Windows [Version 6.2.9200]

     (c) 2012 Microsoft Corporation. All rights reserved.
\end{lstlisting}

\end{document}

Result