After a lot of trying and a lot of blood, sweat and tears I finally found a workaround to make it happen. This is the only solution I came up with and the cmd version I am not completely happy with. Furthermore it includes a few temporary files.
Result for cmd:
startServerCMD.bat
SET currdir=%CD%
SET currdrive=%CD:~0,2%
echo %currdir%
echo %currdrive%
echo %currdrive% > temp.bat
attrib +H temp.bat
echo cd "%currdir%" >> temp.bat
echo server.exe >> temp.bat
shelexec\Release\ShelExec /verb:runas "temp.bat"
del /A:H temp.bat
I then wrote a program in c with icon that executes startServerCMD.bat
Shelexec.exe is a program that I found on the web that lets me run programs from the command line. I didn't find a way to get it to work with the runas command without lots of trouble and filling in a password, so this is a good alternative.
The only problem is that this opens a second cmd window. That is not a problem, as the first will close after it is done with the last line of the bat, but for some reason the first cmd window hangs for a couple of seconds, before it quits.
Lastly I can't get the icon to work for the new cmd window, since it runs the bat file, which has no icon.
Result for PowerShell:
This was a bit more difficult, but I have found a way. It even works more fluently and has a working icon.
startServerPS.ps1
$currdir=$(get-location)
$target = ".\startServer.lnk"
echo "Set oWS = WScript.CreateObject(`"WScript.Shell`")" > temp.vbs
echo $("sLinkFile = `"" + $target + "`"") >> temp.vbs
echo "Set oLink = oWS.CreateShortcut(sLinkFile)" >> temp.vbs
echo "oLink.TargetPath = `"%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe`"" >> temp.vbs
echo $("oLink.Arguments = `"-Command `"`"cd '" + $currdir + "';.\server.exe`"`"`"") >> temp.vbs
echo $("oLink.IconLocation = `"" + $currdir + "\server.ico, 0`"") >> temp.vbs
echo "oLink.Save" >> temp.vbs
cscript temp.vbs
del temp.vbs
attrib +H ".\startServer.lnk"
shelexec\Release\ShelExec /verb:runas "startServer.lnk"
So... This is a PowerShell script that creates a VB script that creates a shortcut which opens the server and then the PowerShell script opens that shortcut with shelexec like before to run it in administration mode. It isn't called a workaround for nothing :D
For easy running (without rightclicking, a shortcut is created for startServerPS.ps1, but not directly. The target is C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& '.\startServerPS.ps1'"