Skip to content
⌘ NSIS Forum Archive

About $CMDLINE in silent install

10 posts

yzldni#

About $CMDLINE in silent install

This is my code:
${If} ${Silent}
${GetOptions} $CMDLINE "/F " $R1
ReadINIStr $1 $R1 "xxxx" "host"
ReadINIStr $2 $R1 "xxxx" "port"
${EndIf}

ps : $R1 is a ".ini" file, this only a example.

Problem:
1.When user install the old version installer, how i display error information. ex:"You have install a newest product, the install will exit now." Because i can't use the MessageBox to show the information in the silent install, i must use a return value in the cmdline... How to resolve this problem?
yzldni#
what?? I want to return a error value and information in the cmdline when i install old version installer, but silent install cat't use messagebox to show this, how can i return in the cmdline
Afrow UK#
If you want to output to a console window (cmd.exe), see this topic:
Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.


Stu
Anders#
Originally Posted by yzldni View Post
I want to return a error value and information in the cmdline when i install old version installer, but silent install cat't use messagebox to show this, how can i return in the cmdline
You can use MessageBox in a silent installer if you want to.

You cannot return "in the cmdline" because that statement does not make any sense. The command line is a string with the parameters the user entered when starting the installer (Ex: Setup.exe /foo /bar).

If you want to write a string to the Console (a.k.a DOS box a.k.a Terminal a.k.a stdout) then you need to say so...
yzldni#
System::Call 'kernel32::GetStdHandle(i -11)i.r0'
System::Call 'kernel32::AttachConsole(i -1)'
FileWrite $0 "hello"
it is show C:\user\administrator\hello

and not show C:\user\administrator\
hello

and it will keep staying, not ending after show "hello" why ????
Anders#
NSIS is a GUI application and writing to stdout like that is a hack. cmd.exe cannot handle this and that's why it ends up like that, there is nothing you can do about it.

Why? cmd.exe sees that it is a GUI application and does not wait, it just prints the current directory right away. Then your setup attaches to the console and starts printing. You now how two processes writing to stdout at the same time and you get timing issues etc.
yzldni#
do you have some way to show

C:\user\administrator\
hello

and not show C:\user\administrator\hello
Anders#
I already told you, there are timing issues here and you don't know exactly when cmd.exe is going to print its line. The best thing you can do is add a newline ($\r$\n) yourself. Even if you do this the state of cmd.exe is going to be weird, you just have to accept that it will never work 100% correctly...