Bonjour,

Je génère un script powershell depuis windev mais il refuse de s'executer.

J'ai bien passé l’exécution des scripts en unrestricted, tenté de lancer l'exe windev en mode admin et le script marche si je le lance depuis l'explorateur windows.

Voici mon code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Procedure executeUpdateLocationPrinter(nomServeurImprimante est une chaîne, nomImprimante est une chaîne, nouvelEmplacement est une chaîne)
 
idFic est un entier
cheminFichierPowershell est une chaîne
 
maCommandePowershell est une chaîne = [
Get-ExecutionPolicy
$printer = Get-WmiObject win32_printer -ComputerName %1 | Where-Object {$_.name -eq "%2"}
$printer.Location = "%3"
$printer.put()
Read-Host "Press ENTER"
]
 
QUAND EXCEPTION DANS
 
maCommandePowershell = ChaîneConstruit(maCommandePowershell,nomServeurImprimante,nomImprimante,nouvelEmplacement)
cheminFichierPowershell = fRepTemp() + [fSep] + "PS_changePrinterLocation.ps1"
idFic = fCrée(cheminFichierPowershell) 
 
SI idFic <> -1 ALORS
fEcrit(idFic,maCommandePowershell)
fFerme(idFic)
LanceAppli("powershell "+cheminFichierPowershell)
fSupprime(cheminFichierPowershell)
FIN
 
FAIRE
ExceptionPropage()
FIN
Si quelqu'un a une idée de comment l’exécuter, ou de comment le traduire en VBScript je suis fortement prenneur.

Merci d'avance,

Bon dev