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 2005 Forums
 Transact-SQL (2005)
 xp_cmdshell & Environment Variable

Author  Topic 

maulikvankawala
Starting Member

2 Posts

Posted - 2010-03-31 : 11:04:37
hello,

I am trying to run a batch file from xp_cmdshell.

It is being run but my batch file uses couble of environment variables and xp_cmdshell does not recognise those environment variable...

actually my working directory and data directory paths are mentioned in environment variables but it gives me error that <environment variable> is missing and takes C:\windows\system32 as a working directory.

any help on this would be appreciated

Maulik

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-03-31 : 12:44:13
I haven't used environment variables in xp_cmdshell before, but I'm wondering if you recently created them and haven't yet restarted the SQL Server service yet. The SQL Server service is already in memory, so it doesn't know about new things added such as when you change the path environment variable.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

maulikvankawala
Starting Member

2 Posts

Posted - 2010-04-02 : 09:37:50
those environment variables are being used by my batch file program from like 2 years. and my server gets reboot on regular maintainance. so as SQL Service also...

I am trying to automate some work and for that I need to call this batch file from sql server.

If I run that batch file manually it perfectly uses those environment variables.

Maulik
Go to Top of Page
   

- Advertisement -