Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 xp_cmdshell

Author  Topic 

hornet
Yak Posting Veteran

96 Posts

Posted - 2006-05-05 : 04:21:07
Hi all! How can I execute exe file using xp_cmdshell? Thanks!

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-05-05 : 04:31:02
xp_cmdshell is running dos commands like...

exec xp_cmdshell 'dir *'

also be cautious, you will get into lot of headaches if you expect user interaction with your exe file, e.g running notepad, msoffice, etc


--------------------
keeping it simple...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-05 : 04:34:19
>>exec xp_cmdshell 'dir *'

should be

exec Master..xp_cmdshell 'dir *'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-05-05 : 04:39:59
yeah, if you're running it on a different database, no need if it's on master



--------------------
keeping it simple...
Go to Top of Page

hornet
Yak Posting Veteran

96 Posts

Posted - 2006-05-05 : 05:19:39
I've been writting next: exec master..xp_cmdshell 'dir C:\Center.exe'. But itsn't running exe file. It show me information about this dir. I need to run file Center.exe. Help me please
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-05 : 05:25:10
exec master..xp_cmdshell 'C:\Center.exe'


KH

Go to Top of Page

hornet
Yak Posting Veteran

96 Posts

Posted - 2006-05-05 : 05:41:47
yea! I've done this. Process was ran, but it was invisible and my QueryAnalizer buzzed after I pressed F5 (Execute Query). I need simply to run this programm.
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2006-05-05 : 08:48:23
Is the C:\xyz.exe on YOUR PC or on the C: of the SERVER?...there is a difference!!!
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-05-05 : 09:30:10
what does your exe do?

if you're loading a form or a program then sql won't do that for you...
it will run exe that run as background processes like sql scripts, transfer tasks, bcp, sendmail, that sort of stuff, without user interaction

it cannot instantiate exe's like notepad, you'll see it in task manager but you won't see the notepad loaded into windows



--------------------
keeping it simple...
Go to Top of Page

hornet
Yak Posting Veteran

96 Posts

Posted - 2006-05-10 : 01:32:09
Thanks a lot! I understood.
Go to Top of Page
   

- Advertisement -