2

I have a python project called the "Remote Dongle Reader". There are about 200 machines that have a "Dongle" attached, and a corresponding .exe called "Dongle Manager". Running the Dongle Manager spits out a "Scan" .txt file with information from the dongle.

I am trying to write a script, which runs from a central location, which has administrative domain access to the entire network. It will read a list of hostnames, go through each one, and bring back all the files. Once it brings back all the files, it will compile to a csv.

I have it working on my Lab/Test servers, but in production systems, it does nto work. I am wondering if this is some sort of login issue since people may be actively using the system. THe process needs to launch silently, and do everything int he background. However since I am connecting to the administrator user, I wonder if there is a clash.

I am not sure what's going on other than tge application works up until the point I expect the file to be there. The "Dongle Manager" process starts, but it doesnt appear to be spitting the scan out on any machine not logged in as administrator (the account I am running off of).

Below is the snippet of the WMI section of the code. This was a very quick script so I apoliogize for any non pythonic statements.

        c = wmi.WMI(ip, user=username, password=password)

        process_startup = c.Win32_ProcessStartup.new()
        process_startup.ShowWindow = SW_SHOWNORMAL
        cmd = r'C:\Program Files\Avid\Utilities\DongleManager\DongleManager.exe'
        process_id, result = c.Win32_Process.Create(CommandLine=cmd,
                                                    ProcessStartupInformation=process_startup)
        if result == 0:
            print("Process started successfully: %d" % process_id)
        else:
            print("Problem creating process: %d" % result)
        while not os.path.exists(("A:/"+scan_folder)):
            time.sleep(1)
            counter += 1
            if counter > 20:
                failed.append(hostname)
                print("A:/"+scan_folder+"does not exist")
                return

        time.sleep(4)

        scan_list = os.listdir("A:/"+scan_folder)
        scan_list.sort(key=lambda x: os.stat(os.path.join("A:/"+scan_folder, x)).st_mtime, reverse=True)
        if scan_list is []:
            failed.append(hostname)
            return

        recursive_overwrite("A:/"+scan_folder+"/"+scan_list[0],
                            "C:\\AvidTemp\\Dongles\\"+hostname+".txt")

Assuming I get a connection (computer on), it usually fails at the point where it either waits for teh folder to be created, or expects something in the list of scan_folder... either way, something is stopping the scan from being created, even though the process is starting

Edit, I am mounting as A:/ elsewhere in the code

4
  • One thing I have noticed... If no user is currently logged in but computer is on, file will not be created Commented Nov 2, 2015 at 16:23
  • 1
    SW_SHOWNORMAL with no logged in desktop may be the problem. Try nothing or SW_HIDE. Commented Nov 2, 2015 at 20:31
  • First test is promising... @tdelaney need to work some other tasks rn before testing against production, will let u know Commented Nov 2, 2015 at 20:42
  • Seems to be working now. Thanks. @tdelaney if you would like credit set it as an answer and I will accept Commented Nov 3, 2015 at 16:00

1 Answer 1

1

The problem is that you've requested to show the application window but there is no logged on desktop to display it. WMI examples frequently use SW_SHOWWINDOW but that's usually the wrong choice because with WMI you are typically trying to run something in the background. In that case, SW_HIDE (or nothing) is the better choice.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.