Jump to content

Create a shortcut in Users\Public\Desktop

Recommended Posts


Because RSAT keeps getting uninstalled when windows installs new updates on the machine I am currently building a script to install it again when the monitor detect its missing.

The scripts works just fine except one thing. Creating the shortcut with nircmd from nirsoft.

In the end of the script I want to put a shortcut to Active Directory Users and Computers to the public desktop (C:\Users\Public\Desktop).

When I do this manually in a CMD I have to right click on CMD and choose run as admin otherwise it will not work, even if the user is local admin on the machine.

With a normal shell in the script I get a OK on that command but it will then fail in the section where the script check if the shortcut is present or not.

With a shell as admin in the script I get a failed login as user when trying to create the shortcut. Do I have to have a valid domain admin or local admin account at the location for this to work?

I have got the script to work 100% but only if I but the shortcut at C:\Users\%username%\desktop but then the user needs to be logged on to the computer for the script to complete.

Can I manage to do the right click and run as admin in the script?

Thanks in advanced! 

Share this post

Link to post
Share on other sites

Review this thread https://www.gavsto.com/why-you-should-almost-never-need-to-run-anything-as-admin-in-automate/

Using normal Shell in a script to create the shortcut in C:\Users\Public\Desktop will work, as long as you're not trying to do anything like copying from a network share that the computer account doesn't have access to.

OK is used when no output is returned from your command. The command is likely your issue (you can try running it on the backend Command Prompt tool within Labtech, or sing backstage to perfect the command, and then run it in Shell)

Share this post

Link to post
Share on other sites

Thanks for your reply.

I dont think that the command is the problem.

As I mention above when I do the exact same command in a CMD at the local computer it does work (if I right click and choose run as admin)


Share this post

Link to post
Share on other sites

Ahh sorry, found the error in the script.

When I check for the shortcut i checked the folloing path C:\users\%username%\dekstop

But I put the shortcut in the public\desktop so of course that will not work.


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...