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
