Autostart
- VB.NET
Sie verwenden einen veralteten Browser (%browser%) mit Sicherheitsschwachstellen und können nicht alle Funktionen dieser Webseite nutzen.
Hier erfahren Sie, wie einfach Sie Ihren Browser aktualisieren können.
Hier erfahren Sie, wie einfach Sie Ihren Browser aktualisieren können.
Es gibt 29 Antworten in diesem Thema. Der letzte Beitrag () ist von Blackbird88.
-
-
msdn.microsoft.com/de-de/library/bb979300.aspx
codeproject.com/KB/dotnet/csregistry01.aspx
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunIch wollte auch mal ne total überflüssige Signatur:
---Leer--- -
Erstmal Danke
habe folgenden code
VB.NET-Quellcode
- Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
- Alias "RegOpenKeyExA" ( _
- ByVal hKey As Long, _
- ByVal lpSubKey As String, _
- ByVal ulOptions As Long, _
- ByVal samDesired As Long, _
- phkResult As Long) As Long
- Private Declare Function RegCloseKey Lib "advapi32.dll" ( _
- ByVal hKey As Long) As Long
- Private Declare Function RegSetValueEx_String Lib "advapi32.dll" _
- Alias "RegSetValueExA" ( _
- ByVal hKey As Long, _
- ByVal lpValueName As String, _
- ByVal Reserved As Long, _
- ByVal dwType As Long, _
- ByVal lpData As String, _
- ByVal cbData As Long) As Long
- Private Declare Function RegDeleteValue Lib "advapi32.dll" _
- Alias "RegDeleteValueA" ( _
- ByVal hKey As Long, _
- ByVal lpValueName As String) As Long
- Public Const HKEY_CURRENT_USER = &H80000001
- Public Const HKEY_LOCAL_MACHINE = &H80000002
- Const KEY_QUERY_VALUE = &H1
- Const KEY_SET_VALUE = &H2
- Const KEY_CREATE_SUB_KEY = &H4
- Const KEY_ENUMERATE_SUB_KEYS = &H8
- Const KEY_NOTIFY = &H10
- Const KEY_CREATE_LINK = &H20
- Const KEY_ALL_ACCESS = KEY_QUERY_VALUE Or KEY_SET_VALUE _
- Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or _
- KEY_NOTIFY Or KEY_CREATE_LINK
- Const ERROR_SUCCESS = 0&
- Const REG_NONE = 0
- Const REG_SZ = 1
- ' Anwendung in Registry eintragen
- '
- ' sDescr: Beschreibung/Bezeichnung
- ' sPath : Pfad inkl. Dateiname der Anwendung
- ' ===========================================
- Public Function SetAutoRun(sDescr As String, _
- sPath As String) As Boolean
- Dim lResult As Long
- Dim KeyHandle As Long
- Dim Key As String
- Const root = HKEY_CURRENT_USER
- Key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
- lResult = RegOpenKeyEx(root, Key, 0, KEY_ALL_ACCESS, _
- KeyHandle)
- If lResult <> ERROR_SUCCESS Then
- SetAutoRun = False
- Exit Function
- End If
- ' +1 für die Null am Ende
- lResult = RegSetValueEx_String(KeyHandle, sDescr, 0, _
- REG_SZ, sPath, Len(sPath) + 1)
- RegCloseKey KeyHandle
- SetAutoRun = (lResult = ERROR_SUCCESS)
- End Function
- ' aus Registry entfernen
- '
- ' sDescr: Beschreibung/Bezeichnung
- ' =================================
- Function RemoveAutoRun(sDescr As String) As Boolean
- Dim lResult As Long
- Dim KeyHandle As Long
- Dim Key As String
- Const root = HKEY_CURRENT_USER
- Key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
- lResult = RegOpenKeyEx(root, Key, 0, _
- KEY_ALL_ACCESS, KeyHandle)
- If lResult <> ERROR_SUCCESS Then
- RemoveAutoRun = False
- Exit Function
- End If
- lResult = RegDeleteValue(KeyHandle, sDescr)
- RemoveAutoRun = (lResult = ERROR_SUCCESS)
- RegCloseKey KeyHandle
- End Function
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If SetAutoRun("Kran iff", "c:\Users\Blackbird\Desktop\VISUAL BASIC\Neuer Ordner\Übungen\Kran iff\Kran if\bin\Debug\Kran iff.exe") Then
- MsgBox("Eintrag war erfolgreich.")
- Else
- MsgBox("Eintrag war nicht erfolgreich.")
- End If
- End Sub
- End Class
wenn ich jetzt auf Button1 klicke bekomm ich die meldung MsgBox("Eintrag war nicht erfolgreich.") warum ? -
-
-
Hi,
das geht viel einfacher, siehe:
VB.NET-Quellcode
- If My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", Application.ProductName, Application.ExecutablePath) IsNot Nothing Then
- My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", Application.ProductName, Application.ExecutablePath)
- End If
Ciao... -
-
-
VB.NET-Quellcode
- Imports System.Security
- Public Class Form1
- Public password As SecureString = New SecureString()
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Me.txtUser.Text = System.Environment.UserName
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- StartNewProcessWithAdminCredentials("C:\MeineAnwendung", Me.txtUser.Text)
- If My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "kran iff", "Kran iif") IsNot Nothing Then
- My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "kran iff", "Kran iif")
- End If
- End Sub
- Private Function StartNewProcessWithAdminCredentials(ByVal ExecutablePathAndName As String, _
- ByVal sUsername As String, _
- Optional ByVal StartArguments As String = "") As System.Diagnostics.Process
- Dim newProcessStartUpInfo As System.Diagnostics.ProcessStartInfo
- Dim ReturnCode As Boolean = False
- Try
- newProcessStartUpInfo = New System.Diagnostics.ProcessStartInfo(ExecutablePathAndName, StartArguments)
- 'XP oder hoeher (Vista = 6)
- If System.Environment.OSVersion.Version.Major >= 5 Then
- newProcessStartUpInfo.Verb = "runas"
- newProcessStartUpInfo.UseShellExecute = False
- newProcessStartUpInfo.Password = password
- newProcessStartUpInfo.UserName = sUsername
- Return System.Diagnostics.Process.Start(newProcessStartUpInfo)
- Else
- Return System.Diagnostics.Process.Start(newProcessStartUpInfo)
- End If
- Catch ex As Exception
- MsgBox(ex.Message)
- Return Nothing
- End Try
- End Function
- Private Sub txtPass_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPass.Enter
- password.Clear()
- End Sub
- Private Sub txtPass_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPass.KeyPress
- Select Case Asc(e.KeyChar)
- Case 33 To 126
- password.AppendChar(ChrW(Asc(e.KeyChar)))
- Case Else
- e.Handled = True
- End Select
- End Sub
- End Class
So hab ich es probiert -
-
-
-
-
-
Probiers mal mit dem Code(autostart zu erstellen)
bei mir geht er. (Win7 32 Bit) -
@Blackbird88
muss man da nicht den schlüssel HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run nehmen?
lg Gugi
edit by kevin89: ein volles Quote ist hier nicht notwendig!Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „kevin89“ ()
-
-
jvbsl schrieb:
beides sind(wie von mir bereits gepostet) richtige Schlüssel, das eine ist jedoch für den aktuellen Benutzer und das andere für alle
muss man nicht wenn man nicht wenn man den schlüssel HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run verwendet, unter projekt -> eigenschaften -> einstellungen für die benutzerkontensteuerung, die zeile
durch
ersetzen?
bei dem HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run muss man ja nur
schreiben, oder?
lg Gugi -
-
-
Tags
-
Ähnliche Themen
-
Schlingel - - Sonstige Problemstellungen
-
2 Benutzer haben hier geschrieben
- Gast (25)
- jvbsl (5)