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.
Who is Participating?
vinnyd79Connect With a Mentor Commented:
The only way to show a window before login is to rewrite the msgina.dll
Here is some info on msgina.dll
I think if you put a string containing your programs path and filename into this key, it will run before someone signs on.


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.
MNetworkAuthor Commented:
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.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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...
MNetworkAuthor Commented:
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.
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?
MNetwork, an EE Moderator will delete this for you.
Moderator, my recommended disposition is:

    DELETE this question (refund points).

DanRollins -- EE database cleanup volunteer
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.