|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Oct 2009
Posts: 4
|
Re: Windows Command Prompt Access from installer script
Is it possible to access the windows command prompt from an NSIS installer script file? In my installer script, I'd like to perform the following actions:
1. ping a server X 1a. if the ping is successful, place the server name X in a registry value 1b. if the ping is unsuccessful, place the server name Y in a registry value I know how to write registry values (WriteRegStr). Unfortunately, I don't see how I could access and interpret a Windows command prompt "dialogue". While accessing the command prompt would be more intuitive to me, just being able to ping and interpret the results would be sufficient for my project. |
|
|
|
|
|
#2 |
|
Major Dude
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
|
Ping may be filtered in customer' network. IMHO better way is a short HTTP request. For example requesting HTTP headers only (or some short file from server). NSISdl included to distribution, but http://nsis.sourceforge.net/Inetc_plug-in has more features.
|
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Oct 2009
Posts: 4
|
Takhir,
Are you suggesting an FTP request instead of a ping to the desired server? The "server X" is just a file server, so I don't know if it could do web requests, etc. Assuming that you mean an FTP request, my only concern would be that the installer script would not know the appropriate user name/password to access the server. If the script doesn't know that information, will your suggestion still work? Thanks again for your help. |
|
|
|
|
|
#4 | |
|
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
Quote:
To answer your ping question, take a look at the nsExec plugin (ExecToLog function). |
|
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Oct 2009
Posts: 4
|
MSG,
Thanks for the info. Here's what I ended up doing: Name "Test" OutFile "Test.exe" Section "" ; returns 1 (error) if ping returned "could not find host" or "request timed out" nsExec::ExecToLog 'ping 192.0.0.1 -n 2 -w 200' Pop $0 ;return value IntCmp $0 0 PingDone MessageBox MB_OK "Defaulting to external address" goto Done PingDone: MessageBox MB_OK "Defaulting to internal address" Done: SectionEnd |
|
|
|
|
|
#6 |
|
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
Err... You're supposed to supply a path to write to, when you use the ExecToLog function. Because it, you know, outputs to a log file. If you just want to pop the return value from ping, use nsExec::Exec.
|
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Oct 2009
Posts: 4
|
OK, thanks for the clarification.
|
|
|
|
|
|
#8 |
|
Major Dude
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
|
jpo, I had in mind http access. But Inetc supports ftp as well. If login/password is not set in URL, you will get answer from server "530" (Anonymous access not allowed)... Or "550" (File not found). "Connection error" if no access to server. But ftp port may be closed as well.
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|