管理通过CMake的NSIS CreateShortCut方法参数的快捷方式 [英] Manage shortcuts arguments for NSIS CreateShortCut method via CMake
问题描述
首先我向大家!
我想创建一个快捷方式,不提示DOS窗口的批处理文件。对于我已经看到下面的命令工作得很好:
I want to create a shortcut to a batch file that does not prompt the DOS window. For that I have seen that the following command works very well:
wscript.exe invisible.vbs my_batch_file.bat
我的问题是,我想创建通过cmake并NSIS此命令的快捷键。我的问题是,它似乎的wscript.exe后,我不能给一个以上的参数在文件的CMakeLists.txt下面的命令:
My problem is that I would like to create the shortcut with this command via CMake and NSIS. My problem is that it seems I cannot give more than one parameter after "wscript.exe" in the following command in the CMakeLists.txt file:
list(APPEND CPACK_NSIS_CREATE_ICONS "
CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\link.lnk' 'wscript.exe' 'invisible.vbs my_batch_file.bat' icon.ico 0 SW_SHOWMINIMIZED
")
和我想象的不解析invisible.vbs和my_batch_file.bat之间的空间(即作为一个空间......)。谁能帮我这个?非常感谢每一个评论(方法或code提示)!
And the space between "invisible.vbs" and "my_batch_file.bat" is not parsed as I expected (i.e. as a space...). Could anyone help me with this ? Thanks a lot for every comment (method or code hint) !
推荐答案
我解决了使用NSIS.template.in文件我的问题,我在其中创建下面的宏
I solved my problem using the "NSIS.template.in" file, in which I created the following macro
!macro CreateShortcutBat link bat_file
CreateShortCut '$SMPROGRAMS\\$STARTMENU_FOLDER\\${link}' 'wscript.exe' 'invisible.vbs ${bat_file}' icon.ico 0 SW_SHOWMINIMIZED
!macroend
然后在我的CMakeLists.txt文件,我只需要调用宏是这样的:
Then in my CMakeLists.txt file, I only need to call the macro this way:
list(APPEND CPACK_NSIS_CREATE_ICONS "
!insertmacro CreateShortcutBat 'Shortcut.lnk' 'my_batch_file.bat'
")
这篇关于管理通过CMake的NSIS CreateShortCut方法参数的快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!