简体   繁体   中英

auto-start java app at windows 8.1 login

I have a java app that I want to auto-start at user login on a clients Windows 8.1 box.

I have created an executable jar on my Windows 8.1 box.

I have converted the jar to a Windows executable via Launch4j .

I have generated a Windows setup executable containing the app and a jre via Inno Setup Script.

I have downloaded the setup executable to the client Windows 8.1 box.

I have run the setup executable on the client box.

In the install directory on the client machine, I have run a powershell ps1 file that successfully creates a shortcut (a .lnk file) to my app in the Windows 8.1 directory structure at:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\mycompanyname

The contents of my powershell ps1 file are:

powershell Set-ExecutionPolicy RemoteSigned

$TargetFile = "C:\Program Files (x86)\mycompanyname\myexecutablename.exe"
$ShortcutFile = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\mycompanyname\mylinkname.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetFile
$Shortcut.Save()
"$TargetFile -NoLog -NoExit"

My reason for running powershell is to create the shortcut link to my app programmatically, rather than have my client user wade through a large number of Windows UI pages.

When I right click on the shortcut and run it as administrator, my app icon appears in the SystemTray as expected. I can right click on the icon and select my various options, and all works well.

However, when I log out, and then log back in, my app icon does not appear in the SystemTray.

How do I get my app icon to appear in the SystemTray after I log out and then log back in?

At this time I am guessing that my powershell ps1 needs to not only create and save my shortcut, but also to set things up such that the app auto-starts at user login.

The end goal is to have my app icon appear in the SystemTray after a user logs in to the Windows 8.1 box, much in the same manner that the app icons for WebRoot, Norton Security Suite, etc., do.

Help, please.

I would use the Registry and the Run key.

More details seen here

Sample.reg shown below.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"MyApplication"="C:\\Program Files\\MyApplication\\1234567.exe"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM