New
#90
@Brink, there are two problems:
1. Did you intentionally or mistakenly disable the commands to automatically get administrative privileges?
2. The following error is not very likely but not impossible.
Now you have a task named "Command Prompt" in Task Scheduler. If you enter the same name via my script, the following message will appear repeatedly.
ERROR: Cannot create a file when that file already exists.
The solution is to close the following window and try again with a different name.
Don't use your translated version. Please use my translated version: Create_an_elevated_shortcut.zip
The error in your version has been corrected, so you don't have to do step 5: right-click on the file and select "Run as administrator". Simply double-click on the file, which will automatically get administrative privileges.
In the new version, some commands have been improved, so you will see the following simple screen, which can be used instead of your screenshots, one of which shows an error message at the top.
Matthew,
The cmd file contains the false assumption that the user's desktop is at %USERPROFILE%\Desktop. Mine, for example, has been relocated to D:\Desktop and so it cannot be found & your script fails to create the elevated shortcut.
- %USERPROFILE%\Desktop cannot cope with relocations,
- %USERPROFILE%\Desktop merely gets resolved into C:\Users\%UserName%\Desktop
See My batch code to find user desktop location - TenForums post for code that will find the Desktop even if it has been relocated.
{The Task works though. I could run it manually then test it with cmds - whoami and reg query "HKU\S-1-5-19" {which would have returned Error: Access is denied if the cmd window had only had standard privileges.}
Denis
Your code has been added into this third version: Create_an_elevated_shortcut.zip
Please check whether it works with your relocated desktop.
Matthew,
Yes, the cmd batch file works. The vbs also works.
[I have read the vbs through but I cannot see where it is referencing the desktop - yet it correctly creates the output file there. What am I missing?]
Denis
@Brink,
Could you use this updated version "Create_an_elevated_shortcut.zip" in your tutorial? It now works with both the default desktop and a relocated desktop.
You have missed the file name "Create an elevated shortcut.cmd", which means the shortcut is created by CMD. I have added your name into the CMD script. I'm afraid that the following VBScript command does not apply to a relocated desktop.
CreateObject("Wscript.Shell").SpecialFolders("Desktop")
Matthew,
Yes, my vbs appreciation is clearly waning & it took another read through them both to realise that the vbs & the cmd file work in tandem [I had assumed, beforehand, that they were independent tools doing the same job as each other].
By the way, in VBS, SpecialFolders("Desktop") does correctly identify my relocated Desktop.
Denis