Exemplo n.º 1
0
def main():
    if len(sys.argv) < 2:
        print("You must specify a command!")
        DumpCommands()
        return
    command = sys.argv[1]
    fn = globals().get(command)
    if fn is None:
        print("Unknown command:", command)
        DumpCommands()
        return

    wincerapi.CeRapiInit()
    try:
        verinfo = wincerapi.CeGetVersionEx()
        print("Connected to device, CE version %d.%d %s" %
              (verinfo[0], verinfo[1], verinfo[4]))
        try:
            fn(sys.argv[2:])
        except InvalidUsage as msg:
            print("Invalid syntax -", msg)
            print(fn.__doc__)

    finally:
        try:
            wincerapi.CeRapiUninit()
        except win32api.error as details:
            print_error(details, "Error disconnecting")
Exemplo n.º 2
0
def main():
    async_init = bStartPython = bDumpRegistry = bDumpFolders = 0
    bDumpStatus = 1
    try:
        opts, args = getopt.getopt(sys.argv[1:], "apr")
    except getopt.error as why:
        print("Invalid usage:", why)
        usage()
        return

    for o, v in opts:
        if o == "-a":
            bStartPython = bDumpRegistry = bDumpStatus = bDumpFolders = asynch_init = 1
        if o == "-p":
            bStartPython = 1
        if o == "-r":
            bDumpRegistry = 1
        if o == "-s":
            bDumpStatus = 0
        if o == "-f":
            bDumpFolders = 1
        if o == "-y":
            print("Doing asynch init of CE connection")
            async_init = 1

    if async_init:
        event, rc = wincerapi.CeRapiInitEx()
        while 1:
            rc = win32event.WaitForSingleObject(event, 500)
            if rc == win32event.WAIT_OBJECT_0:
                # We connected.
                break
            else:
                print(
                    "Waiting for Initialize to complete (picture a Cancel button here :)"
                )
    else:
        wincerapi.CeRapiInit()
    print("Connected to remote CE device.")
    try:
        verinfo = wincerapi.CeGetVersionEx()
        print("The device is running windows CE version %d.%d - %s" %
              (verinfo[0], verinfo[1], verinfo[4]))

        if bDumpStatus:
            print("Dumping remote machine status")
            DumpRemoteMachineStatus()

        if bDumpRegistry:
            print("Dumping remote registry...")
            DumpRegistry(win32con.HKEY_LOCAL_MACHINE)

        if bDumpFolders:
            print("Dumping remote folder information")
            DumpRemoteFolders()

        DemoCopyFile()
        if bStartPython:
            print("Starting remote Python process")
            if DumpPythonRegistry():
                DemoCreateProcess()
            else:
                print("Not trying to start Python, as it's not installed")

    finally:
        wincerapi.CeRapiUninit()
        print("Disconnected")
Exemplo n.º 3
0
        print "The device is running windows CE version %d.%d - %s" % (
            verinfo[0], verinfo[1], verinfo[4])

        if bDumpStatus:
            print "Dumping remote machine status"
            DumpRemoteMachineStatus()

        if bDumpRegistry:
            print "Dumping remote registry..."
            DumpRegistry(win32con.HKEY_LOCAL_MACHINE)

        if bDumpFolders:
            print "Dumping remote folder information"
            DumpRemoteFolders()

        DemoCopyFile()
        if bStartPython:
            print "Starting remote Python process"
            if DumpPythonRegistry():
                DemoCreateProcess()
            else:
                print "Not trying to start Python, as it's not installed"

    finally:
        wincerapi.CeRapiUninit()
        print "Disconnected"


if __name__ == '__main__':
    main()