• 0

Creating Shortcut with NirCmd


Question

Here are the parameters for creating a shortcut with NirCmd:

shortcut [filename] [folder] [shortcut title] {arguments} {icon file}
{icon resource number} {ShowCmd} {Start In Folder} {Hot Key}

I have a difficult problem with a script not related to NirCmd, but
I'm hoping to use NirCmd's ability to create shortcuts.

The shortcut target line (argument) must look like this:

"D:\USB Scripts\HappyScript.exe" /r "D:\OCZ Drives\RunWebApps.sc"

HappyScript.exe runs the command lines in RunWebApps.sc.

Obviously, the quotes are a problem. With NirCmd, each parameter has
a set of quotes. How can I get NirCmd to enter a target line like the
one shown above?

Link to comment
https://www.neowin.net/forum/topic/1229739-creating-shortcut-with-nircmd/
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Use ~q as an embeddable quote.  The parameter part would be something along the lines of: (the whole thing, including the outer quotes)

"/r ~qD:\OCZ Drives\RunWebApps.sc~q"
The regular quotes enclose that one parameter for NirCmd, the ~q gets substituted for a quote in the shortcut itself.

More help under "Special String Sequences"

http://www.nirsoft.net/utils/nircmd2.html#using

  • 0

I didn't think anyone would reply to my post, and there doesn't seem to be a
forum dedicated to all the NirSoft apps.

Thank you Mr. Norris.

I will read the NirCmd help file again. I just finished creating a script with a
different app, so my brain is a little fried.

I understand what you mean by an embeddable quote, but the target line must be
exact. The switch /r should have a space on either side. The executable pathname
and the location of the file containing the commands need a set of quotes. If not,
my script will not run. You show a quote followed by the /r switch ("/r). That puts
the quotes in the wrong place.

I'll experiment with the special character ~q. Hopefully, I can get the target line
correct.

When (or if) I get it right, I'll return to this thread and shoot off some fireworks
for Mr. Norris!

  • 0

Actually the quotes are in the correct place, I just pointed out what you needed to do.  You need to enclose that entire parameter, spaces and all, in quotes for the NirCmd program, otherwise it treats it as different parameters for the NirCmd program. The ~q gets substituted for quotes in the shortcut that it makes. (Why NirSoft didn't use proper escape sequences is beyond me but..)  Spelled out, the full command line would be this:

NirCmd shortcut "~qD:\USB Scripts\HappyScript.exe~q" "C:\" "Shortcut Title" "/r ~qD:\OCZ Drives\RunWebAps.sc~q" "" "" "" "D:\USB Scripts"

Change C:\ to wherever you actually want to create the shortcut, and change the title and icon stuff if it suits you too.  It generates a shortcut with your exact command line.. copy/pasted from the shortcut created:

"D:\USB Scripts\HappyScript.exe" /r "D:\OCZ Drives\RunWebApps.sc"
  • 0

After studying the NirCmd examples in the help file, I opened a text editor and
created a shortcut script using ~q.

It worked the first time!

Mr. Norris, your solution was 100% correct. I've created countless scripts over
many years, but I never had any reason to build a shortcut from the command line.

The script I just completed has hundreds of command lines. It appeared to be
error free. After running the script several times I noticed one serious problem
that seemed to doom my lengthy script to the junk pile.

When I realized NirCmd could create shortcuts from the command line, I was
hoping a "patch" using the shortcut command might save my script.

Anyway, here are your fireworks!

post-41590-0-86211500-1410897537.jpg

  • 0

just tested this.  This will create a notepad shortcut on your desktop.  copy this into a text file and change the extension from txt to vbs.  no need for nircmd, this is built into windows.  you can call vbs scripts from a batch file or call it through a logon script. 

 

 

  Quote

Set oWS = WScript.CreateObject("WScript.Shell")
userProfile = oWS.ExpandEnvironmentStrings( "%userprofile%" )
sLinkFile = userProfile & "\desktop\notepad.LNK"
Set oLink = oWS.CreateShortcut(sLinkFile)
    oLink.TargetPath = "C:\windows\notepad.EXE"
 '  oLink.Arguments = ""
 '  oLink.Description = "Notepad"   
 '  oLink.HotKey = ""
 '  oLink.IconLocation = "C:\windows\notepad.exe"
 '  oLink.WindowStyle = "1"   
 '  oLink.WorkingDirectory = "C:\windows"
oLink.Save

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Isn't the CPU used to calculate the parity for the RAID? If so, the combination of SSDs and 10GBe might make the CPU more important
    • yeah GSMA began working to enable end to end encryption between android and iphone last year and apparently a new standard was developed. apple has said that they would implement this in "future software updates" but i haven't heard anything since march, the time this was all reported on. shortly after, i read on forbes that the FBI suggests not sending texts between iphone and android because they're unencrypted. i use signal to chat with my wife but i'd rather just use messages tbh (she has an iphone), i'm not really a 3rd party guy haha
    • Well, I did not like the trailer for the project he went to work on also, but why do you think he should waste time with this… did you love the season 2? Maybe I am missing out after the crap I saw in first season ep1-3? I love the first last of us game… while not the BEST it was one of the games that I will remember for the EXPERIENCE it game me… last of us 2 was not on the same level at all and the show🤔 complete miss in my experience of the first few level
    • They're likely moving all resources to other things. Clearly Windows is not important to them.
    • Image Uploader 1.4.3 Build 5352 by Razvan Serea Image Uploader is a free and open-source program for Windows that that allows you to effortlessly upload images, screenshots, and various files to a wide array of hosting services. With its capability to capture selected screen areas, it promptly uploads content to image hosting services, while also offering the convenience of automatically copying the URL to your clipboard. Key Features of Image Uploader: Upload to Multiple Hosting Services Image Uploader supports uploading images and files to over 30 popular hosting services. Additionally, it can upload directly to your own FTP, SFTP, or WebDAV server. After upload, the tool automatically generates sharing codes in HTML, BBCode, and Markdown, with support for custom output templates tailored to your needs. Video Frame Grabbing and Screenshot Tools You can extract multiple frames from video files in a wide range of formats including AVI, MP4, MKV, WMV, and more. It supports both system-installed codecs and built-in ones. The extracted frames can be uploaded individually or compiled into a single mosaic image. It also includes screenshot capabilities for the full screen or selected regions, along with a simple image editor for annotations, highlights, and blurring. Advanced Integration and Usability Image Uploader supports drag-and-drop, clipboard monitoring, and can be accessed via Windows Explorer’s context menu. It also features URL shortening, multi-account support, reuploading, and the ability to upload images embedded in text while retaining formatting. The app is available in several languages, including English, Russian, Turkish, Korean, Arabic, and more. Image Uploader 1.4.3 Build 5352 changelog: New Features Screen Recording: Added two powerful capture methods: DirectX (Desktop Duplication API) FFmpeg-based recording Expanded Hosting Services: Added support for new file hosting platforms: TeleBox (linkbox.to) take-me-to.space ranoz.gg webshare.cz lobfile.com imgpx.com freeimghost.net radikal.cloud anonpic.org fotozavr.ru imgtr.ee thumbsnap.com 8upload.com filemail.com Others Video Uploads: Added Flickr.com support for video uploads Localization: New French translation added Context Menu: Added "File Information" option to video file context menus DPI Support: Improved support for: Screen DPI changes Mixed-DPI multi-monitor setups Improvements Disabled application window animations during screenshot/screen recording initiation Updated API and documentation Improved overall stability Bug Fixes Fixed network client error that could cause application crashes Resolved unauthorized startup registration issue Fixed upload functionality for pixeldrain.com Restored tray icon balloon notifications visibility Various minor bug fixes Download: Image Uploader 64-bit | Portable 64-bit | ~16.0 MB | (Open Source) Download: Image Uploader 32-bit | Portable 32-bit | ~15.0 MB Download: Image Uploader ARM64 | Portable ARM64 | ~11.0 MB Links: Image Uploader Home Page | Screenshot | GitHub Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • Reacting Well
      SteveJaye earned a badge
      Reacting Well
    • One Month Later
      MadMung0 earned a badge
      One Month Later
    • One Month Later
      Uranus_enjoyer earned a badge
      One Month Later
    • Week One Done
      Philsl earned a badge
      Week One Done
    • Week One Done
      Jaclidio hoy earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      430
    2. 2
      ATLien_0
      156
    3. 3
      +FloatingFatMan
      149
    4. 4
      Nick H.
      64
    5. 5
      +thexfile
      62
  • Tell a friend

    Love Neowin? Tell a friend!