NSIS是一个GUI程序,并没有真正能够写入stdout.
在XP及更高版本中,您可以使用系统插件执行此操作:
System::Call 'kernel32::GetStdHandle(i -11)i.r0'
System::Call 'kernel32::AttachConsole(i -1)'
FileWrite $0 "hello"
在< XP,没有AttachConsole,你需要在这些系统上调用AllocConsole(可能会打开一个新的控制台窗口) 编辑:
如果父进程没有已有的控制台,则可以打开新控制台
!include LogicLib.nsh
System::Call 'kernel32::GetStdHandle(i -11)i.r0'
System::Call 'kernel32::AttachConsole(i -1)i.r1'
${If} $0 = 0
${OrIf} $1 = 0
System::Call 'kernel32::AllocConsole()'
System::Call 'kernel32::GetStdHandle(i -11)i.r0'
${EndIf}
FileWrite $0 "hello$\n"
但就它而言,它真的没有任何意义吗?处理过,你可以在没有控制台时打开一个消息框
!include LogicLib.nsh
StrCpy $9 "USAGE: Hello world!!" ;the message
System::Call 'kernel32::GetStdHandle(i -11)i.r0' ;try to get stdout
System::Call 'kernel32::AttachConsole(i -1)i.r1' ;attach to parent console
${If} $0 <> 0
${AndIf} $1 <> 0
FileWrite $0 "$9$\n"
${Else}
MessageBox mb_iconinformation $9
${EndIf}