Old 28th April 2010, 21:57   #1
marcellokera
Junior Member
 
Join Date: Apr 2010
Posts: 8
Unhappy Command Prompt Install

Hello,
I am facing two problems with NSIS scripts. I am new on this but if someone could help me would be great...

I have to do a installer that runs from a command prompt. I have to set some parameter that the user needs to set (I have done that already), but if the user doesn´t pass the parameter the installer should show a message on command prompt usage: installer.exe -d <directory>

the other problem is that when I run the uninstall i have to zip the directory and save to a backup, I saw all the plugins but they just extract zip files they don´t create one...

can anyone help me?
marcellokera is offline   Reply With Quote
Old 28th April 2010, 22:07   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
To create Zip files you could include a copy of 7za.exe (7-zip.org) and extract and execute that (with ExecDos/nsExec). The executable is a little on the heavy side but I'm not sure if there are any other freely available command line zippers out there.

Stu

Last edited by Afrow UK; 29th April 2010 at 15:17. Reason: see Anders' post!
Afrow UK is offline   Reply With Quote
Old 28th April 2010, 22:29   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,356
I have coded this several times for other people, try a forum search next time...

On XP and later it can be done perfectly: http://forums.winamp.com/showpost.ph...79&postcount=4

For older platforms, there is no AttachConsole so you would have to call AllocConsole instead on those systems

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 29th April 2010, 13:54   #4
marcellokera
Junior Member
 
Join Date: Apr 2010
Posts: 8
Thanks a lot guys...
Was very helpfull
marcellokera is offline   Reply With Quote
Old 30th April 2010, 15:42   #5
marcellokera
Junior Member
 
Join Date: Apr 2010
Posts: 8
Thumbs up

Hi guys,

I have done this way... thanks for the help

code:

StrCpy $R0 "$\r$\n $R0 $\r$\n"
StrLen $R4 $R0
System::Call "kernel32::AttachConsole(i -1)i .r0"
StrCmp $0 0 end
System::Call "kernel32::GetStdHandle(i -11)i .r0"
System::Call "*(i 0)i .r1"
System::Call "kernel32::WriteConsole(i r0, t R0, i R4, i r1, i 0)"
System::Free $1
System::Call "kernel32::FreeConsole()"
end:

marcellokera is offline   Reply With Quote
Old 30th April 2010, 16:22   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,356
You should not use writeconsole to write plain ansi text, use WriteFile (If you use WriteFile, the output can be redirected and/or piped)

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 30th April 2010, 17:34   #7
marcellokera
Junior Member
 
Join Date: Apr 2010
Posts: 8
Hum ok...
I changed to
System::Call "kernel32::WriteFile(i r0, t R0, i R4, i r1, i 0)"

well I have another question Anders...

Is there a way to keep the prompt right after the command? like

c:\>example.exe -d d: <here comes the error message>

instead of what is doing now
c:\>example.exe -d d:
c:\> Error Message
marcellokera is offline   Reply With Quote
Old 30th April 2010, 18:39   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,356
Quote:
Originally Posted by marcellokera View Post
I changed to
System::Call "kernel32::WriteFile(i r0, t R0, i R4, i r1, i 0)"
The nsis FileWrite command calls WriteFile (See the link I posted)

As far as the newline goes, the answer is yes and no. The short answer is, NO. The long answer is, you have full control over the console buffer and can do anything you want to it by calling the correct windows api's

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
comman prompt, compress file

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump