I try to elevate a Script by using a batch :
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dp0main.ps1""' -Verb RunAs}"
That works fine but the thing is i use a variable in the Script to merge certain paths so i can use the folders within the Folder in which the script is located.
$temppath = Get-Location | Select-Object -ExpandProperty Path
Scriptfolder
|_____Script
|_____BackupFolder
|_____Profilfolder
So what i do is if i need to access on of the folders in a functin i do something like
$backuppath = $temppath + "\BackupFolder"
To make it at least a bit dynamic. The logic problem now is if i execute the Script via the Batch the location that i will will be some system32 path not the origin path of the script because i call it via the prompt.
How could i make it less dependend but still so dynamic that i could run it from everywhere with only the condtion of having the folders in the same location as the script.