Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xp_cmdshell problem

Status
Not open for further replies.

tc3596

Technical User
Mar 16, 2001
283
I've ead many artiles on xp_cmdshell. I can't figure out how to get it to run.

After several attempts on my test server at work, I decided to try it at home. I have SQL 7 installed on my local PC at home. I created a user tc3596 (with sysadmin privs) I log into query analyzer and log into master db.

This code works:
exec xp_cmdshell 'dir *.exe'

This code does not:
exec xp_cmdshell 'calc.exe'

Query Analyzer just keeps running. If I do a ctr-alt-del, I can see the calc.exe process running, but nothing ever comes up on my screen. In fact, even if youtry and stop the query, it is still actually running when you check 'Current Activity' under Management. You have to kill the process. And then it still won't go away. Y9ou have to rstart sql services. Very frustrating. Any thoughts?
 
Programs executed by xp_cmdshell run in the background...

I have used xpcmdshell to create an interactive scheduled task that runs in 1 min using the AT command.. messy but works

Rob
 
OK, that makes me feel a little less crazy. My goal was to open an application every morning at 6 am (M-F). The program is made from VB 6. It runs on a timer, I was just hoping that there would be a more efficient way to start the program. I would need the program to completely be visible to the user as they may have to interact with it at some point in the day.
 
Just a suggestion, but if you are running NT/2K/XP there is the "AT" command. You do need to have the scheduler service running but it will do what you need.

Syntax (from the dos prompt)
AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername Specifies a remote computer. Commands are scheduled on the
local computer if this parameter is omitted.
id Is an identification number assigned to a scheduled
command.
/delete Cancels a scheduled command. If id is omitted, all the
scheduled commands on the computer are canceled.
/yes Used with cancel all jobs command when no further
confirmation is desired.
time Specifies the time when command is to run.
/interactive Allows the job to interact with the desktop of the user
who is logged on at the time the job runs.
/every:date[,...] Runs the command on each specified day(s) of the week or
month. If date is omitted, the current day of the month
is assumed.
/next:date[,...] Runs the specified command on the next occurrence of the
day (for example, next Thursday). If date is omitted, the
current day of the month is assumed.
"command" Is the Windows NT command, or batch program to be run.

For example

AT 14:02 /INTERACTIVE "SOL.exe"
will run solitair at 2 after 2 in the afternoon on the local system..

HTH


Rob


 
Rob,
Thanks for the info. After doing some further reading on the AT command. I found that you can schedule from the Windows Task Scheduler (duh). Sometimes I try to make things too difficult. Although I can't use this for holidays. basically, the program can't run on holidays. I'm going to have to see if there is a way to use the PC's holiday schedule to filter out dates. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top