Is it possible to make a shortcut to a relative path in Windows that runs as admin?

windows shortcut relative path flash drive
how to make a relative path
windows relative path current directory
powershell shortcut relative path
shortcut icon relative path
windows lnk file relative path
relative path to desktop windows
relative paths windows 10

To create a shortcut with a relative path, set the target to the following.

%windir%\system32\cmd.exe /c start your_relpath\app.exe [your_args]

It is also straightforward to make the program run as administrator.

Properties > Advanced > Run as administrator

But putting the two together doesn't work. When cmd.exe is started as admin, it loses the current working directory and goes to %windir%\system32. The relative path starts there which is not intended.

Is there any way to make a shortcut that is both relative and run as admin?

I didn't find an easy way but that's fine. I was concerned that shortcuts with absolute paths would break between computers. I didn't realize that Windows corrected them automatically. This seems sufficient, though relative paths would have been more elegant.

Although shortcuts, when created, point to specific files or folders, they may break if the target is moved to another location. Microsoft Windows has standard algorithms for fixing up shortcuts when they are moved. Windows 9x-based versions of Windows use a simple search algorithm to fix broken shortcuts.[1] On Windows NT-based operating systems and the NTFS file system, the target object's unique identifier is stored in the shortcut file and Windows can use the Distributed Link Tracking service for tracking the targets of shortcuts, so that the shortcut may be silently updated if the target moves to another hard drive.[4]

http://en.wikipedia.org/wiki/File_shortcut#Microsoft_Windows

Shortcut - Create with Relative Path, Because shortcuts' "Start in" is set before elevation occurs, this gets reset during Click on File -> open CMD prompt -> Open CMD prompt as admin and make a the tool at this position is started (in my case 4 runs the cmd as admin). try to shift + rightclick on the specific folder and select open command window here . In this post I will show you this easy method of creating relative shortcuts in windows using the shortcut wizard, follow the steps below: Right-click in the folder you wish to create a shortcut and navigate to “New > Shortcut”. In the Location field type “explorer.exe” and click “Next”.

For a portable shortcut, that works with a relative path, use the following:

Simply drop this in the "Target" of the Shortcut Properties:

%COMSPEC% /C "start GoogleChromePortable.exe -enableextensions -incognito"

Expected behavior: A brief CMD window will popup and close just prior to chrome launching.

Note: the "Start in:" option can be left blank. Also note, the .exe is located in the same folder as the shortcut, but move the folder and the shortcut works just fine.

This is confirmed to work in Win10 1607.

Credit: some other post on stackoverflow a while ago.

How to open Command Prompt in a specific folder as Administrator , Is it possible to: 2) I need the shortcut to run the batch file with a relative path, in order to have a relative path, I need to get somehow current directory path. An elevated Windows process will always start in system32. Is it possible to make a shortcut to a relative path in Windows that runs as admin? (2) For a portable shortcut, that works with a relative path, use the following: Simply drop this in the "Target" of the Shortcut Properties:

Was having trouble with auto-close window behavior. Just got it working with the following:

%COMSPEC% /c "start theRelativePath" | taskkill /F /IM cmd.exe

Getting current directory for shortcut running as admin, Create a shortcut that uses the runas command with the /savecred switch, NOTE: Running an application as a local admin could cause unwanted changes to Click the Manage another account link in the User Accounts window computer and C:\Path\To\Program.exe with the full path of the program you want to run. Windows 9x-based versions of Windows use a simple search algorithm to fix broken shortcuts.[1] On Windows NT-based operating systems and the NTFS file system, the target object's unique identifier is stored in the shortcut file and Windows can use the Distributed Link Tracking service for tracking the targets of shortcuts, so that the shortcut

Create a Shortcut That Lets a Standard User Run An Application as , You can easily create a shortcut that uses the runas command with the user will be able to use the runas /savecred command to run any command as and C:\Path\To\Program.exe with the full path of the program you want to run. The Administrator password is saved in the Windows Credential� Since there´s no Tips & Tricks forum, I assume the better place to post may be here. I´ve seen a lot of people asking how to create shortcuts with relative paths in windows, some say it´s just no supported etc etc At the end of the day there are several ways, like creating a windows shortcut files (.ink) or using a bat file wich can be converted to an exe with an icon file.

How To Create a Shortcut That Lets a Standard User Run An , Create the batch file 2. bat then create a shortcut to it. Oct 23, 2013 � So, can you open a command prompt with run as administrator, then type in the file directory This can prevent your scripts from working correctly if you use relative paths. bat file. To run File Explorer as Administrator in Windows 10, do the following. Hopefully a simple one. I need to run an MMC console as a different username each time. I know I can shirt/right-click and run-as user and this works fine but I can't find anywhere in the shortcut to set the credentials so it always opens under the different user ID.

Run batch file as administrator, You can launch VS Code from the command line to quickly open a file, folder, the PATH environment variable on Windows and Linux automatically during If the specified file does not exist, VS Code will create them for you: Relative paths are relative to the current directory of the command prompt where you run code . Indeed. I check a shortcut to some program on my desktop in the manner described and I get the full path to the actual program. If I looks at something like Outlook 2016 though, all I get with this method is the path to the shortcut. After looking around in web searches I have still not found how to resolve the second case.

Comments
  • I tried this with Target and Start In blank, with a .bat file, but it is not working. I'm looking for a way to run a .bat as admin on a portable key using shortcuts. %COMSPEC% /C "cmd _UTT.bat" worked though, but won't run as admin.