mklink can be run from any command path, therefore I'm trying to run mklink though runas by means of runas /noprofile /users:AdminUser mklink but I can get error that The system cannot find the file specified ? How can I tell runas to run the command mklink as I would when running mklink from any command prompt ?

Dani AI

Generated

Short answer: mklink is a built‑in command of cmd.exe, not a standalone executable. runas looks for a program file, so calling mklink directly with runas will give “The system cannot find the file specified.” Invoke the command interpreter and pass mklink as its argument (use /c to run then exit, /k to keep the shell open for debugging).

Example (replace placeholders with real paths and an actual admin account):

runas /noprofile /user:AdminUser "cmd.exe /c mklink \"<LinkPath>\" \"<TargetPath>\""

To keep the window open so you can see errors:

runas /noprofile /user:AdminUser "cmd.exe /k mklink \"<LinkPath>\" \"<TargetPath>\""

Notes and troubleshooting:

  • discovered the same /k trick — that’s useful for seeing why a command fails.
  • was right to suggest full paths if Windows can’t find the program; if you have problems, specify C:\Windows\System32\cmd.exe explicitly.
  • If you want an elevated shortcut that doesn’t prompt each time, ’s Task Scheduler approach (the one linked earlier) or a scheduled task set to run with highest privileges is a clean alternative. ’s HowToGeek reference is also a good walk‑through for shortcut/task tricks.

Common pitfalls: use /user: (not /users:), quote the whole command passed to runas, and escape nested quotes. Ensure the admin account you supply is enabled and has the rights you expect. If you need a scriptable or non‑interactive solution, consider creating a scheduled task or using PowerShell/New‑Item (symbolic links) depending on your environment.

Recommended Answers

All 4 Replies

If it can't find runas, then why not use the full path. This might vary from PC to PC but here it was C:\Windows\System32\runas.exe
If it can't find mklink then that path could be supplied.

You don'y need to enable the admin account. You can create a shkrtcut to an elevated task via the task scheduler. See here for details.

Passing in the /k flag then the command "mklink cmd" then and only then does it execute.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.