Archive: Change user account question


Change user account question
As part of my installation process, I am creating a new user account (postgres) in Windows 2K and would like to be able to change over to this new account to complete the installation process.

I've been through the archive but haven't seen anything like this. Can it be done, or is it easiest to do a reboot and have the user log on to the new account?

If the latter is the better way to go, are there any examples of how to do this. I have seen a lot of discussion in the archives about different pieces of this but I'm having trouble putting the pieces together, and am hoping there might be an example script that could help me see the process as a whole.

Thanks.

Dave


Since I've had no nibbles, perhaps I should give more detail.

My strategy has been to use a "resume upon reboot" approach. It does resume after reboot, but it starts all the way back at the beginning of the installation instead of jumping to the second part of the installation. (Thus looping again through the reboot process.) I'm not sure if it is my code that is at fault or simply where I am positioning it in the script.

At present I have positioned the code right after the configuration, language and data part of the script--just before the installation sections. The pseudo-code goes like this.

Section 1
Call function to see if there is a "Step" key in HKLM\Software\MySoftware
If yes go to .ResumeFromReboot
SectionEnd

Section 2
Do first part of installation
Write to runonce registry key
Write a "Step" key in HKLM\Software\MyProgram
Reboot
SectionEnd

Section 3
.ResumeFromReboot
Do rest of installation stuff
SectionEnd

Is this structurally how it would be done, or am I on the wrong track?

Dave


So you want a certain user to be logged in after you have restarted the system?


Yep, that's my main purpose. That way I can install and implement a PostgreSQL database more simply. I don't know if I need to go all the way through a reboot to do it or whether there are some system calls I can make that can just do an automatic logoff and logon as 'postgres'.

Dave


Search the MSDN (http://msdn.microsoft.com) for Win32 API calls.

If Windows supports it, you can call the API's using the System plug-in or (when it's complicated) write your own NSIS plug-in.


For the logging off part I found Brainsucker showed how to do the System call-- found it at

http://forums.winamp.com/showthread....hreadid=108930

but when I run his example I get the message that 'System::Fullcall' is an invalid command. Has the System plug-in changed? I am new to using API calls so I am not sure where to go next.


Logging off is not that difficult, but I don't know how to automatically login a certain user. If you can't find an API call, maybe it's not possible.


The new syntax is:

System::Call "User32::ExitWindowsEx(i ${EWX_LOGOFF}, i 0) i .s"
Pop $0
DetailPrint "result - $0"


Excellent! Thank you.