Here is a very nasty way of doing what you want. I'm sure there are better options out there, but it might get you started:

Code:
DECLARE @command varchar(255),@iCount integer

--Create Table Log_CmdOutput (Res VarChar(2000))

set @command = 'Set'

DELETE from  Log_CMDOutput

INSERT INTO Log_CMDOutput values(@Command)

INSERT INTO Log_CMDOutput
EXEC master..xp_cmdshell @Command

Select * From Log_CmdOutPut
Where Res Like 'ProgramFiles%'
HTH