Using the api in window service

Using the api in window service

hx
Advocate Advocate
972 Views
5 Replies
Message 1 of 6

Using the api in window service

hx
Advocate
Advocate

Can the api using in the window service for doing automation calculate?
when I wrote an service.
I found the function GetListOfPmComObjects always return nothing?

 

01.png

01- the powermill is open in widnow desktop

 

 

02.png

02- the GetListOfPmComObjects  function return the instance is 0

 

03.png

03- the service overrides the start sub.

 

0 Likes
Accepted solutions (1)
973 Views
5 Replies
Replies (5)
Message 2 of 6

luke.edwards.autodesk
Community Manager
Community Manager

I've never tried running it as a service. Which user is running the service? It is running as a logged in user or the SYSTEM user? I guess you would need to run it as a user otherwise it won't be able to create the window handles to be able to function correctly. You can change this option in the service properties. But then you will still see the PowerMill window flash up so it might negate why you are looking to do it as a service in the first place...


Luke Edwards
Consulting Services Manager
0 Likes
Message 3 of 6

hx
Advocate
Advocate

@luke.edwards.autodesk 

What I want to do is to use a computer as the server, and then set up the server to automatically receive the projects uploaded by the client and perform some calculations.

The current problem is that under the same computer user, all are administrators. When I use Winform or Console to call the api, GetListOfPmComObjects can feed back the currently running PowerMILL instance, while when I call in Serivce, the returned quantity is 0. I feel very strange. I try to build a new non administrator user, and then try this service to see if there are similar problems.

0 Likes
Message 4 of 6

luke.edwards.autodesk
Community Manager
Community Manager

But why do you need to run it as a service for it to be a server? Do you mean a Windows Service or do you mean something on the back of an ASP type application? How is your service running and how is it receiving jobs?


Luke Edwards
Consulting Services Manager
0 Likes
Message 5 of 6

hx
Advocate
Advocate

The current idea is to use the socket method to transmit data in the LAN, and then use the PowerMILL project uploaded from the client to calculate the queue.

So I thought of using serivce to call the PowerMILL process, open the project, calculate, and feed back the results.

0 Likes
Message 6 of 6

luke.edwards.autodesk
Community Manager
Community Manager
Accepted solution

Ok, so take a look at the properties of your service. Under which user account is that service running? I've provided a screenshot of the settings page I am talking about (in this case I just chose a random service on my computer). You can see that it is running as the Local System Account. But this may cause you issues.

 

I think you could either:

1 - Use the Local System Account but allow it to interact with the desktop by checking the check box

2 - Run the service under a different account (i.e. the logged in user)

 

lukeedwardsautodesk_0-1667988179559.png

 


Luke Edwards
Consulting Services Manager
0 Likes