how to host an exe with a dynamic commandline parameter

若如初见. 提交于 2019-12-11 23:36:55

问题


I have an installer exe which takes a channel_id param as a command line parameter and uses it. The channel_id may be different for different downloads and installs. I want to host my installer exe on web in such a way that when it's downloaded and executed (by double clicking) the channel_id is passed to it in someway ,which should be equivalent to running the installer exe in cmd with channel_id as below.

cmd> myinstaller.exe channel_id.

How is it possible to do so ?


回答1:


You can append data to the end of the .exe file.




回答2:


You can include your param in the name of the file. For example, instead of setup.exe, call it setup_XXXX.exe. Then from NSIS you can read and parse $EXEPATH and extract your param from the filename.




回答3:


Probably not the most reliable way to do this (if there is any), but you could probably check for the Zone.Identifier. I'm not aware of a way to this natively in NSIS, but you might be able to achieve by parsing the result through the commandline.

Try

nsExec::ExecToLog 'more < "$EXEPATH:Zone.Identifier"'

or

nsExec::ExecToLog 'dir /r "$EXEPATH"'

I've also found several Powershell (and VisualBasic) scripts that allow interacting with Alternate Data Streams, but personally I'm not a big fan of using third party scripting languages.



来源:https://stackoverflow.com/questions/18605870/how-to-host-an-exe-with-a-dynamic-commandline-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!