>> That won't work because if you double click the bat file in a \\unc share then you get that error saying the UNC paths are not supported. It then defaults to the Windows directory, so %cd% would be c:\windows in my case. Does Powershell have the same problem? Would it help to use powershell for all your deploy automation?
>> I have a batch file that deploys to the required environment and i'm setting it up to output the deploy script into a folder as part of the build on TFS. I am not what you mean by the 2nd part "i'm setting it up to output the deploy script into a folder" We are using Powershell and msBuild project files and don't have any issues with UNC paths. I think the reason is that we get all variables from MsBuild and those are in the MsDos format: c:\drops\BC03\2013-08-21-06h21\ ... Variables we use: $(WorkingDir) $(SolutionDir) $(ProjectFile) $(PackageDir) .peter.gfader. (current mood = warm sun makes my heart jump and puts a smile on my face) http://blog.gfader.com On Wed, Aug 21, 2013 at 5:22 AM, Stephen Price <[email protected]>wrote: > That won't work because if you double click the bat file in a \\unc share > then you get that error saying the UNC paths are not supported. It then > defaults to the Windows directory, so %cd% would be c:\windows in my case. > > I ended up going with this: > > @set uncpath=%0:\Dev.deployWeb.bat=% > @pushd %uncpath% > ... > > where the first line does a remove of the bat file's name from the %0 > (which is the name of the original call including the full path name... ) > so strip off the known bat file name and I've got the path. Pushd then does > the rest. > > > On Wed, Aug 21, 2013 at 10:35 AM, Preet Sangha <[email protected]>wrote: > >> http://stackoverflow.com/questions/3848597/bat-current-folder-name >> >> set startdir=%cd% >> >> echo %startdir% is my current directory >> >> >> >> On 21 August 2013 13:37, Stephen Price <[email protected]> wrote: >> >>> Hey all, >>> >>> I have a batch file that deploys to the required environment and i'm >>> setting it up to output the deploy script into a folder as part of the >>> build on TFS. >>> Part of the batch file maps a drive using pushd and then the current >>> path of the drop. This changes with each build and contains the build >>> version in the path. >>> >>> I'm trying to work out how to dynamically update this batch file using >>> our current build process... we are transforming a parameters.xml file as >>> well as some app.config file for a windows service and I'm wondering if >>> it's possible to do a transform on a .bat file. (or even a .txt file I can >>> rename at the last step or something). So far I've not found anything >>> indicating if its possible. >>> >>> I may have to just add the registry that allows you to run cmd.exe from >>> \\unc paths (current get an error telling me its not supported but I know I >>> can change that). >>> That will be my workaround if I can't work out how to insert the path >>> the .bat file is run from. Or come up with some fancy .bat file tomfoolery >>> to work out the path it was run from (and pushd that path). >>> >>> CMD.EXE was started with the above path as the current directory. >>> UNC paths are not supported. Defaulting to Windows directory. >>> >>> Hmm.. actually I might be able to do some string manipulation from the >>> %0 to get the path... ahhhh this takes me back. Used to love working with >>> .bat files back in my infrastructure days. hehe >>> >> >> >> >> -- >> regards, >> Preet, Overlooking the Ocean, Auckland >> > >
