Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.fr.scripting > #30 > unrolled thread
| Started by | didou77 <nospam_didier.moreau77120@orange.fr.invalid> |
|---|---|
| First post | 2022-07-31 15:49 +0000 |
| Last post | 2022-07-31 19:58 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to microsoft.public.fr.scripting
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | didou77 <nospam_didier.moreau77120@orange.fr.invalid> |
|---|---|
| Date | 2022-07-31 15:49 +0000 |
| Subject | Re: [HTA] passage de param�tres (�quivalent de "wscript.Arguments sous Wsh) |
| Message-ID | <sfWcnXjI_oXkOXv_nZ2dnZfqlJ_NnZ2d@giganews.com> |
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
[toc] | [next] | [standalone]
| From | Michel__D <Michel.NOSPAM@orange-ft.com.invalid> |
|---|---|
| Date | 2022-07-31 19:58 +0200 |
| Subject | Re: [HTA] passage de paramètres (équivalent de "wscript.Arguments sous Wsh) |
| Message-ID | <tc6fsd$1dkv$1@gioia.aioe.org> |
| In reply to | #30 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | microsoft.public.fr.scripting
csiph-web