Question : Using xp_cmdshell in Query Analyser of SQL Server 2000

Question pertains to SQL Server 2000->Query Analyser
I want to print using xp_cmdshell. When I use xp_cmdshell 'type c:\bill.txt>lpt1', I get a message access denied.

When I try to use xp_cmdshell 'type c:\bill.txt>lpt2' after having configured LPT2 via NET USE command, I get a file unknown message. When I use xp_cmdshell 'type c:\bill.txt>lpt2' from the Command Prompt, it prints fine.

Note : the printer is located on another machine and I have captured port using NET USE. My OS is WinXP and the server is running on a Microsoft Windows Server 2000 running SQL Server 2000.

Thanks

Answer : Using xp_cmdshell in Query Analyser of SQL Server 2000

Hi, we are starting to get into some interesting areas. You might have to create logins / users in SQL for authenticated windows users.

Check out EXECUTE AS (both as a command and in procedures), also check
SELECT * FROM SYS.SERVER_PRINCIPALS
SELECT * FROM SYS.DATABASE_PRINCIPALS

For a list of users. Basically, you can create a procedure that has an exec as clasue and that can nominate a windows user - but there are a few constraints, and you will have to read up a bit.
Random Solutions  
 
programming4us programming4us