Question Création d'un process distant via WMI

Plus d'informations
il y a 12 ans 3 mois #16520 par Richard Lazaro
Bonjour à tous,

Voilà j'ai besoin de créer un process distant en passant via WMI (pour une appli C# à la base)

Le code ci-dessous ne marche pas chez moi, alors que je retoruve le même un peue partout sur le net ...

[code:1]
$computername = \"localhost\"

$mgmtScope = New-Object System.Management.ManagementScope
$mgmtScope.Path.Server = $computername
$mgmtScope.Path.NamespacePath = 'root\default'
$mgmtScope.Options.EnablePrivileges = $true
$mgmtScope.Options.Impersonation = [System.Management.ImpersonationLevel]::Impersonate

$mgmtScope.Connect()

$mgmtGetOptions = New-Object System.Management.ObjectGetOptions
$mgmtPath = New-Object System.Management.ManagementPath -ArgumentList \"Win32_Process\"
$mgmtClass = New-Object System.Management.ManagementClass -ArgumentList $mgmtScope, $mgmtPath, $null

$mgmtBOInParams = $mgmtClass.GetMethodParameters(\"Create\"«»)
$mgmtBOInParams[\"CommandLine\"] = \"notepad.exe\"

$mgmtBOOutParams = $mgmtClass.InvokeMethod(\"Create\", $mgmtBOInParams, $null)
[/code:1]

Il me plante sur le récupération du ManagementClass.

Est ce que cela fonctionne chez vous ?
Avez vous une idée pour le faire fonctionner ?

Bien cordialement,
Richard Lazaro.

Think-MS : (Get-Life).Days | %{ Learn-More }

\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 12 ans 3 mois #16525 par Richard Lazaro
Pour info, j'ai trouvé.
En fait, il faut bien spécifier le bon namespace :

[code:1]
$mgmtScope.Path.NamespacePath = 'root\cimv2'
[/code:1]

voilà voilà ... une demi-journée pour cela :)

Think-MS : (Get-Life).Days | %{ Learn-More }

\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.057 secondes
Propulsé par Kunena