Vinay
Vinay

Reputation: 470

Execute system commands using wmi python on remote computer

I am trying to create a directory on a remote computer using wmi and python. I am able to successfully run any batch file by providing the complete path to it. But not execute system command.

This following code does not create a directory on the remote computer.

conn = wmi.WMI('172.20.23.45', user='Administrator', password='Pass@123')
conn.Win32_Process.Create(CommandLine='mkdir temp')

Upvotes: 3

Views: 8859

Answers (1)

Vinay
Vinay

Reputation: 470

It could be done as.

conn.Win32_Process.Create(CommandLine='cmd.exe /c mkdir temp')

Upvotes: 1

Related Questions