- NSIS Discussion
- Recuperer une valeur de vbscript à nsis
Archive: Recuperer une valeur de vbscript à nsis
Angel89
30th June 2011 11:09 UTC
Recuperer une valeur de vbscript à nsis
Bonjour,
J'ai crée un code en VBscript,et je veux qu'il retourne une valeur true ou false.apres je veux que cette valeur soi recuperé par un fichier nsis (extension .nsi)
VOila mon code sur le script:
Function trouve()
Dim Result
Result=False
if fso.FolderExists(Chemin) Then
Result=true
Else Result=false
End if
Trouve=Result
End Function
à l'excution de mon script, il m'affiche soi vrais soi faut,selon l'existence de mon dossier. Mais est ce que cette valeur peut etre utilisé dans le nsi?
Genre que le nsi verifie si par exemple retourne true (vrais) il affiche un message ,le dossier existe Sinn,le dossier n'existe pas.
Par exemple:
File "Verifier_exist_dossier.vbs"
File "Lancement1.Bat" # c'est lui qui lance le script
Execwait '$Temp\Lancement1.Bat'
!if Trouve=False
MessageBox MB "Exist"
Else MessageBox MB "n'existe pas"
Mais ca ne marche pas le code
Meerci de m'aider
MSG
30th June 2011 11:32 UTC
You can probably get an exitcode / return value from the vbscript launcher. Or you can write to a temporary file, and read that in NSIS. Have you tried googling for something like 'get return value from vbscript'?
Angel89
30th June 2011 12:11 UTC
No! how can i do that please? I'm not professional Developer.Can You write me the code wich i need?
Angel89
30th June 2011 12:16 UTC
Je veux que le nsi vérifie si la valeur retourné par le script est vrais ou faux.si la valeur est vrais,il continue l'instalation,sinn il va afficher un message :
MessageBox MB_ICONEXCLAMATION "Erreur"
Angel89
30th June 2011 12:25 UTC
moi je fais
SetOutPath $Temp
SetOverWrite on
File "Verifier_exist_dossier.vbs"
File "Lancement1.Bat" # c'est lui qui lance le script
Execwait '$Temp\Lancement1.Bat'
!if Trouve=False
MessageBox MB "Exist"
Else MessageBox MB "n'existe pas"
Mais ca en marche pas
jpderuiter
30th June 2011 13:27 UTC
Please write in english, as most users (if not all :) can read english, but maybe not all can read french.
To get a return value from a vbs script:
http://www.tek-tips.com/faqs.cfm?fid=5755
But the solutions are not pretty.
So you better use something else to get what you want.
The scipt you posted can simply be done by NSIS with the IfFileExists (Or ${If} ${FileExists} with LogicLib) command.
The code from your last post will not work indeed, please read the LogicLib documentation
Angel89
30th June 2011 13:32 UTC
the directory is in an xml file,that's why i use a script to get an attribute ...i'm not sure that i can do it with nsis.
Sorry for french
jpderuiter
30th June 2011 13:35 UTC
There are enough possibilities to read xml data:
http://www.google.com/search?aq=f&so...F-8&q=nsis+xml
Angel89
30th June 2011 13:57 UTC
when i execute
nsisXML::Create
nsisXML :: LOAD <i give the directory here> ...i receive this message: Invalid command : nsisXML::Create
Angel89
30th June 2011 15:32 UTC
Yes! I just installer the plugin.
Now how can i get the attribute??
this is part of my xml file:
< v1>
<v2>
<v3 chemin= "c:\Dossier" taille=100>
<\v3>
<\v2>
<\v1>
i want to get the value of the attribute chemin and Test if is present.
This is my new nsi file wich do the test:
outfile test.exe
section Test
nsisXML::Create
nsisXml::Load<$c:\.....>
....... I don't know what should i write in the rest
Help plz ^^
MSG
30th June 2011 15:56 UTC
There is an example in the plugin's readme.txt, and in sample.nsi. You can use those to learn how to use the plugin.
Angel89
30th June 2011 16:49 UTC
I used the examples! But i don't succed.You don't have another easier way to pars the value of an attribute from an XML File?
May Be with Script is easier??
MSG
30th June 2011 21:07 UTC
Well XML files are just plain text files, so you can probably use the macros in textfunc.nsh and wordfunc.nsh to get your value. See the manual: http://nsis.sourceforge.net/Docs/AppendixE.html
T.Slappy
1st July 2011 06:53 UTC
@Angel89: actually we cannot write whole script for you.
Forum is the way to get some clue how to solve a problem.
You need to understand a more of XML and NSIS to write working script.
If anybody writes script for you and later you change something in xml then you will need to ask on this forum again... that is bad approach
Try to understand the problem and learn NSIS or hire someone to write script for you.
This is only general comment, no offense :)
Angel89
1st July 2011 10:43 UTC
Thank You For Your help!
I resolved the problem.
Good luck