Link to home
Start Free TrialLog in
Avatar of MNetwork
MNetwork

asked on

Show window before logon in NT

I need to know how to show a window before someone logs in in an OS such as NT/2K/XP. I have seen this done with programs such as the Cisco VPN client. I know that it requires the program to start as a service, and that you have to do work with the desktops and stuff. I just don't know what to do exactly.
Avatar of fakehampster
fakehampster

I think if you put a string containing your programs path and filename into this key, it will run before someone signs on.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

So this would be your code:
'Begin code:
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Const REG_SZ = 1

Sub SaveString(hKey As Long, strPath As String, strValue As String, strData As String)
    Dim Ret
    'Create a new key
    RegCreateKey hKey, strPath, Ret
    'Save a string to the key
    RegSetValueEx Ret, strValue, 0, REG_SZ, ByVal strData, Len(strData)
    'close the key
    RegCloseKey Ret
End Sub

Private Sub Form_Load()
SaveString "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", , App.Title, App.Path & "\" & App.EXEName
End Sub
'End code.

I haven't tested it, so I wouldn't recommend running it without reviewing it.
Avatar of MNetwork

ASKER

This code wouldn't even work in that os. All you are doing is adding a registry entry that tells windows to run that program AFTER logon.
I guess if you made a DOS compatible program to load Windows then load yours you could put it in the autoexec.bat file. But it might be a different file on different versions of windows. Like autoexec.nt. You could make a program like that with the old QBasic and Quick Basic compilers. I'm pretty sure that's how Nevell did it.
Or you could just put the command to open your program after the "load Windows" commands. But, theres still the problem of the right autoexec file...
OMG, ok, first of all win nt/2k/xp don't use autoexec.bat like that, just 9x. Second even if they did they wouldn't run a win32 file. This is more advanced then you guys can handle. You have to do things with security desktops and stuff.
MNetwork:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
Avatar of DanRollins
MNetwork, an EE Moderator will delete this for you.
Moderator, my recommended disposition is:

    DELETE this question (refund points).

DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial