سؤال

Creating an installer for possible remote systems so that if they do not have something installed, it will start the autorun.exe on their desktop (sure it would be easy to give them the link and they could click start and run... but this would be 100% better if it was done for them!)

Heres the model I have been using and I should mention that I am testing between both a windows 7 and XP machine, although I don't think its too big of a deal.

import wmi
import win32com.client

def Copy_Program(computer=None, environment="Production"):
    Oracle_install = r'\\server1\Install\Oracle\Oracle9i_Disk1\autorun\autorun.exe'


    """  BELOW PROCESS SHOWS UP IN TASKMANAGER, but I NEED IT TO BE INTERACTIVE.
    wmi = win32com.client.GetObject ("winmgmts:\\\\"+computer+"\\root\\cimv2")
    win32_process = wmi.Get ("Win32_Process")
    in_parameters = win32_process.Methods_ ("Create").InParameters
    in_parameters.Properties_ ('CommandLine').Value = "notepad.exe"
    result = win32_process.ExecMethod_ ("Create", in_parameters)
    """  
    SW_SHOWMINIMIZED = 1

    c = wmi.WMI (computer)
    startup = c.Win32_ProcessStartup.new (ShowWindow=SW_SHOWMINIMIZED)
    pid, result = c.Win32_Process.Create (
    CommandLine=Oracle_install,
    ProcessStartupInformation=startup
    )
if __name__ == '__main__':
    Copy_Program(computer = "D02659")

Now as Mr Tim Golden had mentioned in the docs... remoting to another machine is pretty simple... you just

c = wmi.WMI("REMOTE_COMPUTER")

and away you go...

and technically it does work, but its not interactive for some reason... I've also tinkered with the SW_SHOWMINIMIZED values, but I can't seem to understand what I'm doing wrong. I have domain admin, so it shouldn't be an issue... especially since I am logged into both systems at the same time... weird.

Anyhow, help is very much appreciated!

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top