Question Création d'un process distant via WMI
- Richard Lazaro
- Auteur du sujet
- Hors Ligne
- Membre platinium
-
Réduire
Plus d'informations
- Messages : 530
- Remerciements reçus 0
il y a 12 ans 3 mois #16520
par Richard Lazaro
Think-MS : (Get-Life).Days | %{ Learn-More }
\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein
Création d'un process distant via WMI a été créé 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.
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.
- Richard Lazaro
- Auteur du sujet
- Hors Ligne
- Membre platinium
-
Réduire
Plus d'informations
- Messages : 530
- Remerciements reçus 0
il y a 12 ans 3 mois #16525
par Richard Lazaro
Think-MS : (Get-Life).Days | %{ Learn-More }
\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein
Réponse de Richard Lazaro sur le sujet Re:Création d'un process distant via WMI
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
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.063 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les initiés
- Création d'un process distant via WMI