Archive: Running Processes and questsions


Running Processes and questsions
I'm very new to this, so bear with me. I'm trying to switch to NSIS. I have a couple questions:

Are all OCX's DLL's and TLB's registered automatically or do I have to call a function (if so which function)?

I have made a script and tested it, but if my program is running it obviously cannot write to the files (since they are running). How can I check if running processes are running and/or tell the user to stop them before continuing. Does it need a restart? My previous progam installer I believe it made them restart and then it installed the components that couldn't be installed. How do I do this?

Thanks!


I use this (win98):

ClearErrors
Rename C:\SomeDir\App.exe C:\SomeDir\App.exe ;If app.exe is in use, error.
IfErrors 0 +3
MessageBox ...(if you want)
Abort ;(if you want, or do something,)

I also ask IfFileExists, avoid looping. So you can GoTo top and check it again. Can also use IntOp and Sleep to limit the loopin times.


So what exactly will that code do? To me (I'm VERY new even though I know a fair amount of programing languages) it lookslike this: rename the app to the same name. If an error occured messagebox and abort. ?

Ok nevermind I think I have it figured out: (my very first true nsis code (the other was generated and edited by me)


LookForProcesses:
Processes::FindProcess "RSA"
${If} $R0 == "1"
MessageBox MB_OKCANCEL "The ********* Apocalypse Client is still running. It will now be stopped\n\r to continue with the installation." IDOK CloseProcess IDCANCEL Aborter
CloseProcess:
Processes::KillProcess "RSA"
Goto Next
Aborter:
MessageBox MB_OK "Setup Failed. Please close all windows and try again."
Abort
Next:
${If} $R0 == '0'
MessageBox MB_OKCANCEL "Failed to Close. Please try to close with the Task Manager or manually and press OK or press Cancel to stop installation" IDOK LookForProcesses IDCANCEL Aborter
${EndIf}
${EndIf}


Ok anyways the first message box (where I have \n\r) is getting some of the words cut out. Is there a way around this or should I just make it shorter.

It's not \r\n in NSIS, it's $\r$\n.
You are better off using the FCT plugin for this. It tries to close the program first and then only terminates it after a confirmation message box.

See Appendix B of the NSIS manual for DLL/TLB installation and uninstallation.

-Stu


I need help with that plugin. Also where do I put the includemacro? Could you give me an example usage for that plugin if I want it to close rsa.exe?

EDIT: I've figured that includemacro goes in the section part after file. Finding a starting point in NSIS was hard, literally. In the help files there should be something along the lines of:

Structure of a basic install
-declarations
-macros
-Following lines to define nsis variables

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "install.exe"
InstallDir "$PROGRAMFILES\ProductName"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show

-Sections to define extraction from exe and to define copy from outside files, script and custom elements here.

Section MainProgram
SetOutPath "$INSTDIR" ;file on user system, destination, other values listed below
SetOverwrite on ;other values listed below
File "myprog.exe" ;file on build system, if on drive c would conform to C:\myprog.exe

End Section

Section Uninstall
;uninstall section use delete and RMDIR (For directories) to delete files

End Section

-here I would put a list of constants and stuff (like where $INSTDIR is and where $SYSDIR is etc.

It would help newbies like me to quickly start making an installer. I had to go through some random help files and make an installer (bad generated code BTW) with HM NIS edit.

Anyways thanks so far but I still don't get that plugin you described. Does it look for window titles? hWnds? What defines what it looks for. Doesn't seem to have a EXE file paramater.


PLug-in finds application by it's window, 2 string parameters - window title and class. Can find by title or class substring. First sends WM_CLOSE to all windows found, after this (if application still alive) terminates program. To get window class string you can use spyxx.exe (included to MS VS). Put included to zip dll to NSIS/plugins folder before installer compile.