Using xp_cmdshell in MS SQL 7.0 - TechRepublic
General discussion
January 31, 2001 at 10:26 AM
shmaltz

Using xp_cmdshell in MS SQL 7.0

by shmaltz . Updated 25 years, 4 months ago

The following question looks more complicated than it really is. That is if you know SQL.
Here is the config:
Winnt Server 4.0 SP6, 256MB RAM, allmost full System partition.
Here is the problem:
when I use a trigger or query analyzer to execute the master..xp_cmdshell it will not work on *.exe.
Here is what I tried:
start>run: “ping www.yahoo.com” results: OK
In query analyzer: “exec master..cmdshell ‘ping www.yahoo.com'” results: OK
Start>run: “notepad.exe” results: OK
In query analyzer: “exec master..xp_cmdshell ‘notepad.exe'” results: Query analyzer froze.
I created a batch file called test.bat saved it in c:\, the following was the commands in the test.bat:
@echo off
echo Im here
pause
when i ran it in dos or start workedfine ran it from query analyzer thru xp_cmdshell worked fine. However if to the above batch file i added the command to run a *.exe file it whould run in regular dos (start or command prompt) but whould not run from xp_cmdshell.
when I tested ipconfig it worked even in xp_cmdshell.

What Im trying to do is run a custom program to whenever a record is updated in tableX. That program is writen in VB. The program works fine from a dos prompt but will not work from xp_cmdshell.
If xp_cmdshell is not made to run windows programs than whats the sullotion to run a program from within SQL thru a trigger?

This discussion is locked

All Comments