I have a problem with creating a shortcut that opens a certain program in Powershell. It is part of a small game server. Therefore the server folder needs to be able to be copied, to create another server.
The program needs to be run in administrator mode. It needs to work for both cmd an powershell (I don't mind if they are 2 different shortcuts due to syntax). What I have so far:
CMD:
%SystemRoot%\System32\cmd.exe /c D: & cd "D:\Path\to\server\folder\" & Server.exe
PowerShell:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command "cd 'D:\Path\to\server\folder\';.\Server.exe"
The problem is that these paths aren't relative, so if I move the server folder, I would need to change the shortcut's target by replacing the path in the cd command.
It would be easier if I could use relative paths (the shortcut is located in the same folder as server.exe), but both the cmd as the PowerShell shortcut start in system32, because it is run in admin mode.
What can I do to make it work by creating at most 1 file for PS and 1 file for cmd (lnk, bat, ps1, I don't care)
EDIT: I also tried the following, but it didn't work:
C:\Windows\System32\cmd.exe /k cd & runas /user:<machine name>\<username> server.exe
the problem is that first of all it asks me the password of the account (it is the same account), which is annoying. Secondly it opens the server in a separate window: one where I can't scroll or rightclick. And lastly, the folder it operates in is wrong, because it can not find files that are in the folder it should operate in.
Does anyone have a better idea?