How to connect to a remote Windows machine to execute commands using python?

后端 未结 11 2102
青春惊慌失措
青春惊慌失措 2020-11-29 20:20

I am new to Python and I am trying to make a script that connects to a remote windows machine and execute commands there and test ports connectivity.

Here is the cod

11条回答
  •  日久生厌
    2020-11-29 21:12

    For connection

    c=wmi.WMI('machine name',user='username',password='password')
    
    #this connects to remote system. c is wmi object
    

    for commands

    process_id, return_value = c.Win32_Process.Create(CommandLine="cmd.exe /c  ")
    
    #this will execute commands
    

提交回复
热议问题