Here's one possibility:
With[{n = 4, k = 4},
StringJoin[Riffle[Table["*", {#}] & /@ #, "|"]] & /@ FrobeniusSolve[Table[1, {k}], n]]
{"|||****", "||*|***", "||**|**", "||***|*", "||****|", "|*||***", "|*|*|**", "|*|**|*",
"|*|***|", "|**||**", "|**|*|*", "|**|**|", "|***||*", "|***|*|", "|****||", "*|||***",
"*||*|**", "*||**|*", "*||***|", "*|*||**", "*|*|*|*", "*|*|**|", "*|**||*", "*|**|*|",
"*|***||", "**|||**", "**||*|*", "**||**|", "**|*||*", "**|*|*|", "**|**||", "***|||*",
"***||*|", "***|*||", "****|||"}
In a comment, Jim shows that you can use IntegerPartitions[] + Permutations[] instead:
With[{n = 4, k = 4},
StringJoin[Riffle[Table["*", {#}] & /@ #, "|"]] & /@
Flatten[Permutations /@ IntegerPartitions[n + k, {k}] - 1, 1]]
which should yield the same result as above.
The OP also wanted to consider the case where empty slots are not allowed; a slight modification of Jim's suggestion does this. Using a different example:
With[{n = 7, k = 4},
StringJoin[Riffle[Table["*", {#}] & /@ #, "|"]] & /@
Flatten[Permutations /@ IntegerPartitions[n, {k}], 1]]
{"****|*|*|*", "*|****|*|*", "*|*|****|*", "*|*|*|****", "***|**|*|*", "***|*|**|*",
"***|*|*|**", "**|***|*|*", "**|*|***|*", "**|*|*|***", "*|***|**|*", "*|***|*|**",
"*|**|***|*", "*|**|*|***", "*|*|***|**", "*|*|**|***", "**|**|**|*", "**|**|*|**",
"**|*|**|**", "*|**|**|**"}
With[{n = 4, k = 4}, StringJoin[Riffle[Table["*", {#}] & /@ #, "|"]] & /@ (-Table[1, {k}] + # & /@ Flatten[Permutations[#] & /@ IntegerPartitions[n + k, {k}], 1])]doesn't seem to require the removal of dupes and is just slightly faster. – JimB Nov 15 '19 at 00:15{{4,1,1,1}, {1,4,1,1}...}etc.? – mf67 Nov 15 '19 at 23:23/@is the numerical version; e.g.Flatten[Permutations /@ IntegerPartitions[n, {k}], 1]. – J. M.'s missing motivation Nov 15 '19 at 23:46