Skip to content

LabVIEW范例:如何让程序在系统启动时自启动

License

Notifications You must be signed in to change notification settings

NEVSTOP-LAB/LabVIEW-Program-run-on-startup

Repository files navigation

LabVIEW-Program-run-on-startup

LabVIEW范例:如何让程序在系统启动时自启动

Note

Example 依赖 NEVSTOP-Programming-Palette.

需要了解

  1. MSDN:Run and RunOnce Registry Keys
Use Run or RunOnce registry keys to make a program run when a user logs on.
The Run key makes the program run every time the user logs on,
while the RunOnce key makes the program run one time, and then the key is deleted.
These keys can be set for the user or the machine.

The data value for a key is a command line no longer than 260 characters.
Register programs to run by adding entries of the form description-string=commandline.
You can write multiple entries under a key.
If more than one program is registered under any particular key,
the order in which those programs run is indeterminate.

The Windows registry includes the following four Run and RunOnce keys:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

  1. Pass Command Line Arguments to a LabVIEW Executable

image

How-To

  1. 创建复用VI,用于创建导入注册表的包含自启动信息的 reg 文件.

Tip

如果中文出现乱码如何处理:修改 reg文件的编码方式,设置为 ANSI 或 UTF-16 LE 编码。 reg文件导入注册表后出现中文乱码的解决方法

Tip

此VI已包含在 NEVSTOP-Programming-Palette 4月Rleases 的 application Palette中,直接生成的reg 文件是 UTF-16 LE 编码.

image

  1. 合适的地方调用,范例中,在 EXE 启动后,每次都创建一次,保证 exe 路径发生变化后,注册表信息也能及时更新

image

  1. 按照 Pass Command Line Arguments to a LabVIEW Executable 配置编译 exe

  2. 运行 exe后, 双击 reg 文件, 将自启动信息导入注册表,重启系统后,程序会自启动, 可以在任务管理器中查看到启动项。

image

About

LabVIEW范例:如何让程序在系统启动时自启动

Topics

Resources

License

Stars

Watchers

Forks