anchor.diff:  	return exec("net session >nul 2>&1") -- fails if not admin
   end
   
  +-- rename file (full path) to backup (name only), appending number if required
  +-- returns the new name (name only)
  +local function backup(filename, backupname)
  +	local path = filename:match("(.+)%\\.-$").."\\"
  +	local nname = backupname
  +	local i = 0
  +	while exists(path..nname) do
  +		i = i + 1
  +		nname = backupname..tostring(i)
  +	end
  +	exec([[REN "]]..filename..[[" "]]..nname..[[" > NUL]])
  +	return nname
  +end
   
   -- interpolate string with values from 'vars' table
   local function S (tmpl)
  
positive.code: -- ***********************************************************
  
  print(S[[
  *** LuaRocks is installed! ***
  
   You may want to add the following elements to your paths;
  PATH     :   $LUA_BINDIR;$FULL_PREFIX
  LUA_PATH :   $ROCKS_TREE\share\lua\$LUA_VERSION\?.lua;$ROCKS_TREE\share\lua\$LUA_VERSION\?\init.lua
  LUA_CPATH:   $ROCKS_TREE\lib\lua\$LUA_VERSION\?.dll
  
  ]])
  os.exit(0)
  
negative.code: if not exists(vars.SYSCONFDIR) then
  	mkdir(vars.SYSCONFDIR)
  end
  if exists(vars.CONFIG_FILE) then
  	local nname = backup(vars.CONFIG_FILE, "config.bak")
  	print("***************")
  	print(S"*** WARNING *** LuaRocks config file already exists: '$CONFIG_FILE'. The old file has been renamed to '"..nname.."'")
  	print("***************")
  end
  local f = io.open(vars.CONFIG_FILE, "w")
  f:write([=[
  rocks_servers = {
     [[http://luarocks.org/repositories/rocks]]
  }
  rocks_trees = {
  ]=])
  if FORCE_CONFIG then
  	f:write("    home..[[/luarocks]],\n")
  end
  f:write(S"    [[$ROCKS_TREE]]\n")
  f:write("}\n")
  if vars.SCRIPTS_DIR then
  	f:write(S"scripts_dir=[[$SCRIPTS_DIR]]\n")
  end
  f:write("variables = {\n")
  if USE_MINGW and vars.LUA_RUNTIME == "MSVCRT" then
  	f:write("    MSVCRT = 'm',   -- make MinGW use MSVCRT.DLL as runtime\n")
  else
  	f:write("    MSVCRT = '"..vars.LUA_RUNTIME.."',\n")
  end
  f:write(S"    LUALIB = '$LUA_LIBNAME'\n")
  f:write("}\n")
  f:write("verbose = false   -- set to 'true' to enable verbose output\n")
  f:close()
  
  print(S"Created LuaRocks config file: $CONFIG_FILE")
  
  
  print()
  print("Creating rocktrees...")
  if not exists(vars.ROCKS_TREE) then
  	mkdir(vars.ROCKS_TREE)
  	print(S[[Created system rocktree    : "$ROCKS_TREE"]])
  else
  	print(S[[System rocktree exists     : "$ROCKS_TREE"]])
  end
  
  vars.LOCAL_TREE = os.getenv("APPDATA")..[[\LuaRocks]]
  if not exists(vars.LOCAL_TREE) then
  	mkdir(vars.LOCAL_TREE)
  	print(S[[Created local user rocktree: "$LOCAL_TREE"]])
  else
  	print(S[[Local user rocktree exists : "$LOCAL_TREE"]])
  end
  
  -- Load registry information
  