Nutshell Posted September 15, 2014 Share Posted September 15, 2014 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, butI'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 hasa set of quotes. How can I get NirCmd to enter a target line like theone shown above? Link to comment Share on other sites More sharing options...
0 Max Norris Posted September 15, 2014 Share Posted September 15, 2014 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 goretsky 1 Share Link to comment Share on other sites More sharing options...
0 Nutshell Posted September 16, 2014 Author Share Posted September 16, 2014 I didn't think anyone would reply to my post, and there doesn't seem to be aforum 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 adifferent app, so my brain is a little fried.I understand what you mean by an embeddable quote, but the target line must beexact. The switch /r should have a space on either side. The executable pathnameand 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 putsthe quotes in the wrong place.I'll experiment with the special character ~q. Hopefully, I can get the target linecorrect.When (or if) I get it right, I'll return to this thread and shoot off some fireworksfor Mr. Norris! Link to comment Share on other sites More sharing options...
0 Max Norris Posted September 16, 2014 Share Posted September 16, 2014 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" Link to comment Share on other sites More sharing options...
0 Nutshell Posted September 16, 2014 Author Share Posted September 16, 2014 After studying the NirCmd examples in the help file, I opened a text editor andcreated a shortcut script using ~q.It worked the first time!Mr. Norris, your solution was 100% correct. I've created countless scripts overmany 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 beerror free. After running the script several times I noticed one serious problemthat seemed to doom my lengthy script to the junk pile.When I realized NirCmd could create shortcuts from the command line, I washoping a "patch" using the shortcut command might save my script.Anyway, here are your fireworks! Link to comment Share on other sites More sharing options...
0 sc302 Veteran Posted September 16, 2014 Veteran Share Posted September 16, 2014 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. 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 Link to comment Share on other sites More sharing options...
Question
Nutshell
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
Share on other sites
5 answers to this question
Recommended Posts