Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.fr.scripting > #31

Re: [HTA] passage de paramètres (équivalent de "wscript.Arguments sous Wsh)

From Michel__D <Michel.NOSPAM@orange-ft.com.invalid>
Newsgroups microsoft.public.fr.scripting
Subject Re: [HTA] passage de paramètres (équivalent de "wscript.Arguments sous Wsh)
Date 2022-07-31 19:58 +0200
Organization M_Douillard
Message-ID <tc6fsd$1dkv$1@gioia.aioe.org> (permalink)
References <#gMhFS3jFHA.3448@TK2MSFTNGP12.phx.gbl> <sfWcnXjI_oXkOXv_nZ2dnZfqlJ_NnZ2d@giganews.com>

Show all headers | View raw


Le 31/07/2022 à 17:49, didou77 a écrit :
> Le samedi 23 Juillet 2005 à 12:51 par sympatix :
>> bonjour !
>>
>> J'aurais besoin de passer  en paramètres le path d'un dossier
>> dans une application HTA (en vbs),
>> en faisant un copier-coller du dit dossier sur mon fichier
>> HTA (exactement comme on peut faire un passage de paramètres en
>> VbScript
>> sous Wsh, à l'aide de l'objet "Wscript.arguments", mais qui
>> malheureusement,
>> n'est pas disponible dans un contexte HTA.
>> Est-ce faisable sans mettre en oeuvre une trop grosse usine à gaz, et
>> si
>> oui, comment ?
>>
>> merci d'avance :-)
>> -- 
>> Cordialement
>> Sympatix
>> (Antispam: Ôter les "toto" dans l'adresse, pour me
>> répondre)
> Bonjour,
> Un petit utilitaire qui récupère l'argument passé au .hta
> MyApp.hta "MyArg"
> N'oubliez pas les guillemets
> et le met dans un fichier: MyArgHTA.txt
> Soit j'utilise un fichier d'échange, soit j'utilise ceci (Je maille moulte
> langages différents, DOS, VB, C, Java) pour mes applications.
> 
> Dim oFSO
> 
> Dim StrComputer
> Dim sCommLine
> Dim c, Disp
> Dim oArg
> 
> 
> 
>    			Set oFSO     = CreateObject("Scripting.FileSystemObject")
> 
> 
> 
> 	StrComputer = "."
> 	Disp        = ""
> 	c           = ""
> 
> 
>      Set objWMIService = GetObject("winmgmts:" _
>          & "{impersonationLevel=impersonate}!\\" & StrComputer & "\root\cimv2")
>      Set colProcessList = objWMIService.ExecQuery _
>          ("Select * from Win32_Process Where Name = 'mshta.exe'")
> 
>      	For Each objProcess in colProcessList
> 		sCommLine = UCase(objProcess.CommandLine)
> 		c = c & sCommLine & vbcrlf
> 
> 		sCommLine = Replace(sCommLine, Chr(34), "")
> 		sCommLine = Trim(sCommLine)
> 
> 		Select Case UCase(Right(sCommLine, 3))
> 		Case "EXE", "HTA"
> 		Case Else
> 				Disp = Disp & sCommLine
> 		End Select
>      	Next
> 	For i = Len(Disp) To 1 Step -1
> 		If Mid(Disp, i, 1) = " " Then Exit For
> 	Next
> 				oArg = Mid(Disp, i +1)
> 
> 
> 
> 	Set oMf = oFSO.CreateTextFile("MyArgHTA.txt", True)
>     			oMf.WriteLine(Disp)
> 			oMf.WriteLine(oArg)
> 	oMf.Close
> 
> 
> 
> 	Set oFSO = Nothing
> 		WScript.Quit
> 

Il y a beaucoup plus simple avec la propriété commandLine liée à l'Objet HTA

PS: J'espère que la personne a trouvée depuis 2005.

Back to microsoft.public.fr.scripting | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [HTA] passage de param�tres (�quivalent de "wscript.Arguments sous Wsh) didou77 <nospam_didier.moreau77120@orange.fr.invalid> - 2022-07-31 15:49 +0000
  Re: [HTA] passage de paramètres (équivalent de "wscript.Arguments sous Wsh) Michel__D <Michel.NOSPAM@orange-ft.com.invalid> - 2022-07-31 19:58 +0200

csiph-web