Reteriving current directory in batch file.


Today I ran into a strange scenario, there was a need to create a batch file which will create a service.

Now the problem is service installation path was unknown to me and for any service to install it needs to its executable’s absolute path.

After doing some hit & trial and googling, came across the solution:

ECHO “Creating some service”

SET CURRENT_DIR=%CD%

sc create someService binPath= %CURRENT_DIR%”\someService.exe” start= demand obj=  password=

Hope  this helps!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s