Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get running as specific user to work #89

Open
drone1 opened this issue May 13, 2015 · 18 comments
Open

Can't get running as specific user to work #89

drone1 opened this issue May 13, 2015 · 18 comments

Comments

@drone1
Copy link

drone1 commented May 13, 2015

The documentation says this:

By default, it will run using the user account that launched the process (i.e. who launched node app.js).

However, if I put this in app.js:

var username = process.env['USERPROFILE'].split( path.sep )[2];

And log it, I get 'system32' rather than my username.

If I put that same printout in the appservice.js file (which creates the Service object, etc), it prints the username I would expect, which is my username.

I've tried explicitly overriding the Service instance's user object with my credentials and domain name, but that doesn't help either. I get 'system32' in that case as well.

Anyone know if this is a bug, or if I'm doing something wrong?

Thanks in advance!

@coreybutler
Copy link
Owner

You're probably better off looking for the last element in the path than hardcoding the 3rd element:

var username = process.env.USERPROFILE.split(path.sep).pop();

The code above will split the string and return the last "directory", which should match up with the username.

@drone1
Copy link
Author

drone1 commented May 13, 2015

OK, thanks for that.

So now the username prints out as "systemprofile" rather than "system32" from app.js even if I specify my domain/username/password via the Service's user object in my service.js file. So, service.js prints out my username, but app.js prints out systemprofile, with or without me explicitly setting a domain/user/password.

Any idea what I need to do to get app.js to run as my user? Thanks a bunch.

@drone1
Copy link
Author

drone1 commented May 18, 2015

Hi, any update on this corey? If you follow my repro steps, can you get app.js to run as a specific user? Any help would be much appreciated, as this will make a feature I've been working on a lot more useful.

@coreybutler
Copy link
Owner

If you open the windows services, right click on the service name, and look at the properties, which user account is the script setup to run as?

@drone1
Copy link
Author

drone1 commented May 25, 2015

So I finally figured this part out and it was NOT set to my username. It was the default/system user.

On Mon, May 25, 2015 at 11:55 AM, Corey Butler [email protected]
wrote:

If you open the windows services, right click on the service name, and look at the properties, which user account is the script setup to run as?

Reply to this email directly or view it on GitHub:
#89 (comment)

@coreybutler
Copy link
Owner

That's what I was guessing... glad you figured it out!

@drone1
Copy link
Author

drone1 commented May 25, 2015

But setting the username in the node-windows settings doesn't work, because even with my credentials and domain, it installs the service as the system user. So there still may be a bug here.

On Mon, May 25, 2015 at 5:09 PM, Corey Butler [email protected]
wrote:

That's what I was guessing... glad you figured it out!

Reply to this email directly or view it on GitHub:
#89 (comment)

@coreybutler coreybutler reopened this May 26, 2015
@doArcanjo
Copy link

@coreybutler
Copy link
Owner

@doArcanjo - I don't really know... node-windows only supports versions of Windows that haven't reached EOL. I haven't (nor intend to) looked at intricacies of supporting anything prior to Windows 7.

@drone1
Copy link
Author

drone1 commented May 26, 2015

This is 7.

On Tue, May 26, 2015 at 4:07 PM, Corey Butler [email protected]
wrote:

I don't really know... node-windows only supports versions of Windows that haven't reached EOL. I haven't (nor intend to) looked at intricacies of supporting anything prior to Windows 7.

Reply to this email directly or view it on GitHub:
#89 (comment)

@doArcanjo
Copy link

7 and 8, and 8.1 not xp althought

@drone1
Copy link
Author

drone1 commented May 27, 2015

Wat

On Wed, May 27, 2015 at 7:33 AM, doArcanjo [email protected]
wrote:

7 and 8, and 8.1 not xp althought

Reply to this email directly or view it on GitHub:
#89 (comment)

@coreybutler
Copy link
Owner

I was just commenting on @doArcanjo's post on the article, which is referencing Vista.

@griff
Copy link

griff commented Jun 15, 2015

winsw has an option in the XML called serviceaccount which it looks like node-windows isn't setting.

@liu-jianyang
Copy link

@griff I'm actually running into this issue right now, and I tried to modify the code to add the option. However, the service still starts running as local system. Would you happen to have any thoughts?

@tishma
Copy link

tishma commented Feb 11, 2016

@liu-jianyang It's not possible to change the owner of the service process (which is managed in Services management console) inside javascript code. The idea behind svc.user options is to configure the account that runs node app wrapped inside the windows service. Does that help?

@liu-jianyang
Copy link

Ah ok, that helps, thanks. So there is no way to change the owner via javascript?

@tishma
Copy link

tishma commented Feb 17, 2016

Oh! You mean at the time of windows service installation! There must be a cmd line script switch (install
script just wraps a windows tool), but I wouldn't know. Anyone?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants