RafaelFranckilin Posted October 7, 2019 at 01:02 PM Report Share #616303 Posted October 7, 2019 at 01:02 PM Pessoal, eu preciso colocar meu programa para iniciar junto com o windows, mas meu programa tem um arquivo de configuração (app.config), como eu faço? agradeço desde já. Link to comment Share on other sites More sharing options...
M6 Posted October 7, 2019 at 01:49 PM Report Share #616305 Posted October 7, 2019 at 01:49 PM Para arrancar com o Windows a melhor solução passa por criares um serviço que arranque com o sistema operativo. Quando tens uma aplicação, em especial se tiver GUI, terás de ter um utilizador autenticado no sistema, se tal for possível, podes colocar na pasta de arranque/start up. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to comment Share on other sites More sharing options...
RafaelFranckilin Posted October 7, 2019 at 01:54 PM Author Report Share #616307 Posted October 7, 2019 at 01:54 PM Na verdade eu gostaria que ele iniciasse com o windows apenas uma vez, eu consegui fazer isso adicionando uma chave no registro nesse caminho "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", mas ele não encontra o arquivo de configuração (app.config). Link to comment Share on other sites More sharing options...
programadorvb6 Posted November 7, 2019 at 04:27 PM Report Share #616545 Posted November 7, 2019 at 04:27 PM (edited) ' Botão para iniciar programa com windows Public Sub AdicionarAplicacaoAoIniciar() Try Using key As RegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True) key.SetValue(caminho, """" + Application.ExecutablePath + """") End Using Catch Throw End Try End Sub ' Para desactivar arranque com o windows Public Sub RemoverAplicacaoAoIniciar() Try Using key As RegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True) key.DeleteValue(caminho, False) End Using Catch Throw End Try End Sub Private Sub btnIniciarApp_Click(sender As Object, e As EventArgs) Try AdicionarAplicacaoAoIniciar() Catch ex As Exception MessageBox.Show("Erro " + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.[Error]) End Try End Sub Private Sub btnRemoverAppRegistro_Click(sender As Object, e As EventArgs) Try RemoverAplicacaoAoIniciar() Catch ex As Exception MessageBox.Show("Erro " + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.[Error]) End Try End Sub Edited November 7, 2019 at 04:28 PM by programadorvb6 ______________________________________________________________________________ Que minha coragem seja maior que meu medo e que minha força seja tão grande quanto minha fé. Link to comment Share on other sites More sharing options...
RafaelFranckilin Posted January 22, 2020 at 01:17 PM Author Report Share #617167 Posted January 22, 2020 at 01:17 PM Muito obrigado pela ajuda, mas esse exemplo funcionaria se o meu programa estiver configurado para abrir apenas como administrador do sistema? Esse meu programa é portable, eu levo no pendrive para usar em vários computadores e tenho um arquivo de configuração (app.config) junto com ele, da ultima vez que tentei iniciar ele com o sistema, ele não encontrou o app.config. Em 07/11/2019 às 13:27, programadorvb6 disse: ' Botão para iniciar programa com windows Public Sub AdicionarAplicacaoAoIniciar() Try Using key As RegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True) key.SetValue(caminho, """" + Application.ExecutablePath + """") End Using Catch Throw End Try End Sub ' Para desactivar arranque com o windows Public Sub RemoverAplicacaoAoIniciar() Try Using key As RegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True) key.DeleteValue(caminho, False) End Using Catch Throw End Try End Sub Private Sub btnIniciarApp_Click(sender As Object, e As EventArgs) Try AdicionarAplicacaoAoIniciar() Catch ex As Exception MessageBox.Show("Erro " + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.[Error]) End Try End Sub Private Sub btnRemoverAppRegistro_Click(sender As Object, e As EventArgs) Try RemoverAplicacaoAoIniciar() Catch ex As Exception MessageBox.Show("Erro " + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.[Error]) End Try End Sub Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now