找回密码
 加入
搜索
楼主: cj-reggie

[网络通信] 通过wmi使用计划任务启动批量远程win7系统的某个应用程序

 火.. [复制链接]
发表于 2012-6-5 20:30:41 | 显示全部楼层
说实话我还有其他方法,怕不通用,你确定你上边的show不出界面吗?哈哈,非常感谢
RemoteExecute("c:\windows\system32\calc.exe")                                                      ; This works - executes on local pc

Func RemoteExecute($strProgToRun)
    Local $objWMIService, $objProcess, $objProgram

    $objSWbemLocator = ObjCreate("WbemScripting.SWbemLocator")
    If Not IsObj($objSWbemLocator) Then
        MsgBox(0, "Error", "Error: failed to create $objSWbemLocator")
        Exit
    EndIf

    $objWMI = $objSWbemLocator.ConnectServer(".", "root\cimv2")    ; This works for remote pc if pass actual credentials and works for local if pass null credentials
    If Not IsObj($objWMI) Then
        MsgBox(0, "Error", "Error: failed to create $objWMI")
        Exit
    EndIf

    $objWMI.Security_.ImpersonationLevel = 3

    $objProcess = $objWMI.Get("Win32_Process")

    $objProgram = $objProcess.Methods_("Create").InParameters.SpawnInstance_
    $objProgram.CommandLine = $strProgToRun

    $objWMI.ExecMethod("Win32_Process", "Create", $objProgram)                                          ; Execute the program now at the command line.

EndFunc
发表于 2012-6-5 20:34:05 | 显示全部楼层
回复 16# 502762378


    晕,还没有远程测试一高兴给妄言了,不过还有一种曲线法,明天测试
发表于 2012-6-5 21:03:57 | 显示全部楼层
回复 15# cj-reggie
谢谢分享这么好的代码,收藏了!
 楼主| 发表于 2012-6-6 14:20:59 | 显示全部楼层
本帖最后由 cj-reggie 于 2012-6-7 14:25 编辑

回复 17# 502762378


    弄出来了分享一下哈,我这边觉得这条路已经到头了
论坛里其实有个大神已经做出来了,只是没源码g
更正,那个大神的也是只能创建进程,没有图形界面,我查了网上相关的,说是用户权限问题,wmi远程运行程序只能在后台,需要给相应权限在当前活动界面下进行交互,依然努力中。。。
 楼主| 发表于 2012-6-7 07:29:11 | 显示全部楼层
继续顶起求给力
发表于 2012-6-7 09:53:06 | 显示全部楼层
我也正在做这方面的脚本,学习之。
 楼主| 发表于 2012-6-7 18:15:51 | 显示全部楼层
再次顶起求大神指点
发表于 2012-6-7 22:03:47 | 显示全部楼层
回复 22# cj-reggie
我也在关注中,座等~~~~
发表于 2012-6-12 10:47:00 | 显示全部楼层
本帖最后由 502762378 于 2012-6-12 10:49 编辑

回复 19# cj-reggie


    测试失败了。你说的权限是$objWMI.Security_.ImpersonationLevel=3这句。我试过了么用,给你我的法子试试吧,代码不多,但自以为是我在公司后台“杀人越货”的神作
#include <Date.au3>
#include <Constants.au3>
_atexec(@ComputerName,"calc.exe")

Func _atexec($strComputer,$execfile)
        $stime = StringSplit( _DateAdd( 'n',1, _NowCalc())," ")
        $stime_addn1= StringTrimRight($stime[2],3)
Run(@ComSpec & " /k at  \"&$strComputer&" "&$stime_addn1&" /interactive cmd /c start "&$execfile,@SystemDir,@SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
EndFunc

评分

参与人数 1金钱 +30 收起 理由
cj-reggie + 30

查看全部评分

发表于 2012-6-12 11:06:28 | 显示全部楼层
顶一下先,学习了
 楼主| 发表于 2012-6-12 16:06:43 | 显示全部楼层
本帖最后由 cj-reggie 于 2012-6-13 20:36 编辑

回复 24# 502762378


    哈哈,我也转向计划任务了,不过用wmi的,批量部分总是报错,还在努力中
 楼主| 发表于 2012-6-14 09:42:35 | 显示全部楼层
继续顶起,求大神指点
 楼主| 发表于 2012-6-14 14:23:55 | 显示全部楼层
回复 24# 502762378


    你的这个我测试确实能用,需要都是用户名密码相同的机器即可,问题是时间上应该再延迟一分钟,不然批量的时候有的机器会因为延迟而错过计划任务运行时间
 楼主| 发表于 2012-6-27 15:52:32 | 显示全部楼层
改问win7下如何做到了,xp下已经成功
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-5 02:10 , Processed in 0.069208 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表