Windows控制台应用程序exe在安装时未调用main方法,系统已注销并重新登录 [英] Windows console application exe is not calling the main method when installed and system is logged off and logged in back

查看:125
本文介绍了Windows控制台应用程序exe在安装时未调用main方法,系统已注销并重新登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows控制台应用程序exe在安装时没有调用main方法,系统已注销并登录后我创建了一个Windows控制台应用程序,然后使用Visual Studio Installer创建了一个EXE ==>设置项目。我的要求是该应用程序在系统重新启动或注销/登录时自动启动。冷杉这个,我在安装项目中添加了Windows启动文件夹的快捷方式。安装exe后,它会自动启动。我可以在任务管理器中查看。但是当系统重新启动或注销并登录时,exe无效。虽然,在任务管理器中它显示为一个正在运行的进程,但主要方法没有被调用。有人能帮帮我吗?我尝试过:在LocalMachine中注册入口>软件> Microsoft> Windows> CurrentVersion>在CurrentUser中运行注册表项>软件> Microsoft> Windows> CurrentVersion>运行



< b>我尝试了什么:



上面

Windows Console Application exe is not calling the main method when installed and system is logged off and logged in back I have created a windows console application and then its EXE using Visual Studio Installer ==> Setup Project. My requirement is that this application starts automatically when system reboots or is logoff/login . Fir this, i added the shortcut to Windows startup folder in setup project. After installing the exe, it gets start automatically. I can check this in task manager. But when system gets re start or log off and log in, the exe is not working. Though, in task manager it is showing as a running process but the main method is not getting called. Can anyone help me inn this? What I have tried: registery entry in LocalMachine>SOFTWARE>Microsoft>Windows>CurrentVersion>Run registery entry in CurrentUser>SOFTWARE>Microsoft>Windows>CurrentVersion>Run

What I have tried:

Above

推荐答案

有问题你的代码因为没有没有调用Main方法这样的东西。如果您的控制台应用程序位于任务管理器中,则调用Main方法。期间,讨论结束。



但是,由于我们看不到你的代码,我们无法告诉你你做错了什么。
There is a problem with your code because there is no such thing as "the Main method isn't being called". If your console app is in Task Manager, your Main method was called. Period, end of discussion.

But, since we can't see your code, we can't possible tell you what you did wrong.


也许在 Windows Startup文件夹中添加快捷方式会有所帮助,请参阅:如何在任何计算机上启动程序运行 [ ^ ]

但是你可能已经尝试过了。

Windows 10中的一个问题是,如果设置了'管理员'权限,快捷方式将无效。



可以在这里找到一些好的答案:启动文件夹中的EXE未运行已解决 - Windows 10论坛 [ ^ ]



在Windows 10中启动需要管理员访问权限的程序,只需创建一个快捷方式(我在任何地方使用Startup文件夹),选中以管理员身份运行,然后在启动文件夹中创建一个简短的批处理文件,并使用'start'命令启动快捷方式(省略.lnk扩展名)和路径,否则启动将无法正常工作,因此请先使用cd更改为快捷方式目录。示例:

Maybe putting a shortcut in the Windows Startup folder will help, see: How to Make a Program Run at Startup on Any Computer[^]
But you probably already tried that.
A problem in Windows 10 is that the shortcut won't work if 'Administrator' privileges are set.

Some good answers can be found here: EXE in Startup folder not running Solved - Windows 10 Forums[^]

To run a program requiring admin access at startup in Windows 10, just create a shortcut (anywhere, I used the Startup folder itself) with "run as administrator" checked, then create a short batch file in the startup folder and use the 'start' command to launch the shortcut (omit the .lnk extension and the path, else start won't work, so use 'cd' to change to the shortcut directory first). Example:
@echo off
cd "C:\Users\...\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
start ThrottleStop


以编程方式执行此操作的方法是使用任务计划程序,这是一个显示手动方式的示例:没有UAC提示的高级程序快捷方式 - 创建 - Windows 7帮助论坛 [ ^ ]

有几种方法可以通过 API 或通过 DOS 命令对任务计划程序进行编程。

为简单起见,我会建议使用DOS命令。

祝你好运:)
A way to do it programmatically is to use Task Scheduler, here is an example that shows the manual way: Elevated Program Shortcut without UAC Prompt - Create - Windows 7 Help Forums[^]
There are several ways to program Task Scheduler, via the API, or via DOS commands.
For simplicity I would recommend using DOS commands.
Good luck :)


这篇关于Windows控制台应用程序exe在安装时未调用main方法,系统已注销并重新登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆