Let $n>4$ be a positive integer, which is divisible by $4$. We denote by $A_n$ the sum of the odd positive divisors of $n$. We also denote $B_n$ the sum of the even positive divisors of $n$, excluding the number $n$ itself. Find the least possible value of the expression $$f(n)=B_n-2A_n,$$
for all possible values of $n$, as well as for which positive integers $n$ this minimum value is attained.
1. **Define the problem and variables:**
   Let \( n > 4 \) be a positive integer divisible by \( 4 \). We denote by \( A_n \) the sum of the odd positive divisors of \( n \) and by \( B_n \) the sum of the even positive divisors of \( n \), excluding \( n \) itself. We aim to find the least possible value of the expression \( f(n) = B_n - 2A_n \).

2. **Express \( n \) in terms of its prime factors:**
   Let \( n = 2^k \cdot m \), where \( m \) is odd and \( k \geq 2 \).

3. **Sum of odd divisors \( A_n \):**
   Since \( m \) is odd, the odd divisors of \( n \) are the same as the odd divisors of \( m \). Therefore, \( A_n = \sum_{d \mid m} d \).

4. **Sum of even divisors \( B_n \):**
   The even divisors of \( n \) can be written as \( 2^i \cdot d \) where \( 1 \leq i \leq k \) and \( d \) is an odd divisor of \( m \). Thus,
   \[
   B_n = \sum_{i=1}^{k} 2^i A_n - n.
   \]

5. **Case \( k = 2 \):**
   \[
   B_n = 2A_n + 4A_n - n = 6A_n - n.
   \]
   Therefore,
   \[
   B_n - 2A_n = 6A_n - n - 2A_n = 4A_n - n.
   \]
   Since \( A_n \geq m + 1 \) (as \( n > 4 \)), it follows that
   \[
   B_n - 2A_n \geq 4(m + 1) - 4m = 4.
   \]
   Equality holds if \( A_n = m + 1 \), which happens when \( m \) is a prime.

6. **Case \( k = 3 \):**
   \[
   B_n = 2A_n + 4A_n + 8A_n - n = 14A_n - n.
   \]
   Therefore,
   \[
   B_n - 2A_n = 14A_n - n - 2A_n = 12A_n - n.
   \]
   Since \( A_n \geq m + 1 \),
   \[
   B_n - 2A_n \geq 12(m + 1) - 8m = 4m + 12.
   \]
   For \( n = 8 \) (i.e., \( k = 3 \) and \( m = 1 \)),
   \[
   B_n - 2A_n = 12 \cdot 1 - 8 = 4.
   \]

7. **Case \( k \geq 4 \):**
   \[
   B_n = 2A_n + 4A_n + 8A_n + \cdots + 2^k A_n - n.
   \]
   Therefore,
   \[
   B_n - 2A_n = (2 + 4 + 8 + \cdots + 2^k)A_n - n = (2^{k+1} - 2)A_n - n.
   \]
   Since \( A_n \geq m + 1 \),
   \[
   B_n - 2A_n \geq (2^{k+1} - 2)(m + 1) - 2^k m = 2^{k+1} m + 2^{k+1} - 2 - 2^k m = 2^k m + 2^{k+1} - 2.
   \]
   For \( k \geq 4 \), this value is strictly greater than 4.

8. **Conclusion:**
   The least possible value of \( f(n) = B_n - 2A_n \) is \( 4 \), and it is attained when \( n = 4p \) where \( p \) is an odd prime or when \( n = 8 \).

The final answer is \( \boxed{ 4 } \).