views:

103

answers:

1

Hi Everyone,

I'm creating a batch file for SharePoint deployment. The batch will do solutions installation and configuration, create a web application and restore the .dat file on the created web application.

Instead of hard code the solutions path and .dat I want batch to know it is on the root. So, if I move this folder somewhere else I won't need to update the paths.

Is there any keyword of batch command which can tell where I stand (batch file directory)?

The batch script sample:

@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm"

Echo copy solution files ...
%STSADM% -o addsolution -filename SmilingGoat.SharePoint.WebParts.Rss.wsp
%STSADM% -o deploysolution -name SmilingGoat.SharePoint.WebParts.Rss.wsp -immediate -allowgacdeployment -allcontenturls

%STSADM% -o addsolution -filename ReturnOfSmartPartv1_3.wsp
%STSADM% -o deploysolution -name ReturnOfSmartPartv1_3.wsp -immediate -allowgacdeployment -allcontenturls

Echo creating Learning Pitch application ... 
%STSADM% -o unextendvs -url http://server:70

%STSADM% -o restore -url http://server:70 -filename 2010.02.03.dat -overwrite

IISRESET

PAUSE

Thanks.

+1  A: 

As far as I understand, %~p0 is what you are looking for.

For instance, if you create a file containing

echo %~p0
pause 

and run it from c:\temp it will output "c:\temp".

EDIT: Actually this answer in SO explains the idea.

naivists
But I have no idea, *why* it is named like this. I've used it since I found it in some example script, but the semantics behind the variable name is unclear to me.
naivists
@naivists thanks! i'll check it out. do you have any idea how to show preloader text like "..." and make it animated.
Ramiz Uddin
If the server where you are installing the package, has PowerShell installed, you can create a `.ps1` script instead of `.bat`. Then you can use "progress indicator" - http://technet.microsoft.com/en-us/magazine/2008.03.powershell.aspx?pr=blog
naivists