Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1422 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  Lancement de script VBS a partir d'un script VB

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Lancement de script VBS a partir d'un script VB

n°1320134
Gainsbourg
Posté le 07-03-2006 à 13:26:59  profilanswer
 

Salut tout le monde,
 
Je vous explique mon probleme qui me hante depuis deja 3 jours.
 
Je dois lancer un script VBS qui se trouve dans un certains repertoire accompagne de certains fichier config propre a l'installation d'un certain programme.
 
J'ai besoin de lancer ce script VBS a partir d'un autre script VB que l'administrateur a fait, le probleme est que je recupere l'erreur suivante :
 
Line 14  
Char 1  
Error File not found  
Code 800A0035  
source Microsoft VBScript runtime error  
 
Et quand je lance le VBS direcement sans passer par le VB tout se passe bien.
 
J'aimreais donc avoir votre opinion sur le sujet, j'ai pense a integrer directement mon VBS a mon VB mais je ne c'est pas comment faire.
 
Merci de votre aide.
 
Ici mon fichier VBS, je suis desole j'arrive pas a faire de quote et j'ai pas eu le temps de mettre les balise.
 
 
 
 
 
 
 
Set WshShell = WScript.CreateObject("WScript.Shell" )
Dim path : path = WshShell.ExpandEnvironmentStrings("%SystemRoot%\temp\3rdParty" )
Dim installdir : installdir = WshShell.ExpandEnvironmentStrings("%SystemDrive%\Program Files\eEye Digital Security\Blink" )
 
Dim backuppath : backuppath = installdir
Dim tmppath : tmppath = ""
Dim newpath : newpath = ""
Dim  TristateFalse : TristateFalse= 0
Dim filesys, file, ts
Const ForAppending = 8
Const ForReading = 1
 
Set filesys = CreateObject("Scripting.FileSystemObject" )
Set file  = filesys.GetFile("settings.txt" )
Set ts =  file.OpenAsTextStream( ForReading )
 
 
'parse the MSI options file and see if the expanded paths are present
Do While Not ts.AtEndOfStream
 if InStr(ts.ReadLine, "INSTALLDIR=" ) > 0 Then  
  AlreadyModified = 1
 End if
Loop
 
if AlreadyModified = 0 Then
 
 'Append the expanded paths to the MSI configuration file (settings.txt)
 Set ts =  file.OpenAsTextStream( ForAppending )
 ts.WriteLine("INSTALLDIR=" & installdir)
 ts.WriteLine("THIRDPARTY=" & path & "\eeyeremoteinstall.exe" )
 ts.Close
 
End If
 
 
Dim nIndex  
 
nIndex = InStr(backuppath, "\" )
 
while  nIndex > 0
 
 tmppath = Left(backuppath, nIndex)
 backuppath  = Right(backuppath, Len(backuppath) - nIndex)
 
 newpath = newpath + tmppath
 
 If Not filesys.FolderExists(newpath) Then  
     Set newfolder = filesys.CreateFolder(newpath)
 End If
 
 nIndex = InStr(backuppath, "\" )
 
Wend
 
 
If Len(backuppath) > 0 Then  
 
    newpath = newpath + backuppath
 
 If Not filesys.FolderExists(newpath) Then  
     Set newfolder = filesys.CreateFolder(newpath)
 End If
 
End If
 
path = WshShell.ExpandEnvironmentStrings("%SystemRoot%" ) & "\temp"
 
'create c:\windows\temp\3rdparty
if filesys.FolderExists(path) = 0 Then
 filesys.CreateFolder(path)
End If  
 
if filesys.FolderExists(path & "\3rdparty" ) = 0 Then
 path = path &  "\3rdparty"
 filesys.CreateFolder(path)
End If  
 
path = WshShell.ExpandEnvironmentStrings("%SystemRoot%\temp\3rdParty" )
 
'get the current folder
set file  = filesys.GetFile("settings.txt" )
filesys.CopyFolder file.ParentFolder , path
 
 
 
Set WshShell = WScript.CreateObject("WScript.Shell" )
 
 
WshShell.Run "cmd /K CD " & path & " & Setup /qn /qb+ /Liom " & chr(34) & installdir & "\BlinkSetup.log" & chr(34) & " OPTIONFILE=" & chr(34) & path & "\settings.txt" & chr(34)
 

mood
Publicité
Posté le 07-03-2006 à 13:26:59  profilanswer
 

n°1320698
Gainsbourg
Posté le 08-03-2006 à 08:39:36  profilanswer
 

Voila la partie de code de mon VB qui vloque selon moi :
 
MsgBox "starting installation"
    errReturn = Shell("wscript.exe ""SetupLaunch.vbs""" )
    MsgBox errReturn

n°1320738
olivthill
Posté le 08-03-2006 à 10:00:38  profilanswer
 

La question est intéressante et expliquée en détail, donc il serait domage que personne n'y réponde. Aussi, je vais essayer d'intervenir bien que je ne dispose pas de VB et ne puisse pas faire de tests, et que je vais peut-être raconter des bêtises.
 
1. Dans ce cas là, faut-il utiliser wscript.exe ?
Peut-être que ça marcherait mieux avec cscript.exe.
 
2. Pourquoi mettre des guillemets autour de SetupLaunch.vbs ?
Les guillemets ne sont utiles que lorsque le nom du fichier contient des espaces.
 
3. Ne serait-il pas plus prudent de mettre le chemin complet plutôt que le nom d'un fichier ?
C'est-à-dire errReturn = Shell("wscript.exe c:\toto\SetupLaunch.vbs" )
 
4. Est-ce que ça marche si on remplace SetupLaunch.vbs par un fichier qui ne contiendrait qu'une seule ligne qui serait Wscript.Echo "coucou" ?
 
5. Est-ce que c'est l'instruction shell ou system qu'il faut utiliser ?

n°1320756
Gainsbourg
Posté le 08-03-2006 à 10:19:15  profilanswer
 

Merci de ta reponse, je repond rapidement au test que j'ai deja realiser et je tente les autres :
 
1 - Le resultat est identique avec cscript
 
2 - Je recois la meme erreur avec ou sans les guillemets
 
3 - Je recois toujours la meme erreur, meme en mettant le chemin du fichier.
 
4 - Ca marche par exemple si on remplace le .vbs par un .exe
 
5 - Je pense que c'est l'introduction shell, mais je vais tester avec system.
 
Merci pour ta reponse

n°1320793
Gainsbourg
Posté le 08-03-2006 à 11:03:25  profilanswer
 

J'ai remarquer qu'il faut que mon script soit lance dans le meme repertoire que le vbs et les fichier config pour que cela marche.
 
Bizarre non ?

n°1320881
Gainsbourg
Posté le 08-03-2006 à 13:23:59  profilanswer
 

Ayyye j'ai resolu mon probleme tout eest la :
 
http://support.microsoft.com/default.aspx/kb/276011


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  Lancement de script VBS a partir d'un script VB

 

Sujets relatifs
creer table à partir d un datatablePb: telechargement plugin java en html lors du lancement d'une applet
Probleme avec un script {RESOLU}Probleme avec un script
[RESOLU]Créer une instance Excel à partir de Word 97 ou 2003Ecrire le résultat d'un script python dans un fichier texte
[RESOLU] Créer un fichier à partir de 2 autres + insérer contenu...[.NET & COM] Gérer Excel à partir de .NET 2005
VBS & ADSIScript vbs Erreur 800A0046 Permission denied
Plus de sujets relatifs à : Lancement de script VBS a partir d'un script VB


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR