Solved

nssm service installer,how to run as Logon-Allow service to interact with desktop for a specific user

Posted on 2016-10-06
27
82 Views
Last Modified: 2016-10-25
My PC have 2 administrators: Admin1 and Admin2,now i wanna try to run a batch file as SYSTEM  for a specific user (in this case Admin1) and allow service to interact with desktop,ok so i found this interesting tool called:'' nssm service installer'', 1'st step is to set application path: C:\Program Files\massi\autorunner.bat now comes the 2'nd step and the most important: (Logon tab)- so if i set ''Local System Account'' - Allow service to interact with desktop and then  i restart my PC then ''autorunner.bat''  runs inside Admin2 acc. and that's not good.If i set Log on as- This account (Admin1) and i restart my PC then ''autorunner.bat'' runs inside Admin1 acc.  only but in backround so i can't make it run as System-Admin1 and also Allow service to interact with desktop
The main idea is how to make ''autorunner.bat'' run on Desktop as SYSTEM for Admin1 only ?
P.S.

Admin1 and Admin2 or Admin100 (all will remain Administrators),i can't and i don't want to modify this
thank you

I take a snapshot for you to understand better:

EasyCapture1.jpg
0
Comment
Question by:john lambert
  • 17
  • 10
27 Comments
 
LVL 53

Expert Comment

by:McKnife
ID: 41831335
To run something as system account, I advise you to download and use psexec.
On an elevated command prompt, simply launch
psexec -s -i notepad
(for example).
1
 

Author Comment

by:john lambert
ID: 41831405
So i paste the psexec.exe here: C:\
Then i run this: psexec -s -i "C:\Program Files\massi\autorunner.bat"

this is the res.:

PsExec could not start C:\Program Files\massi\autorunner.bat on WINXPBE-697375:
The system cannot find the file specified.
0
 
LVL 53

Expert Comment

by:McKnife
ID: 41831408
It does not seem to be the correct path. double check.
1
 

Author Comment

by:john lambert
ID: 41831410
Ok for XP dones't work, i test inside windows 7 and said this:


Ok for my windows 7 rdp worked, find the path etc, i run cmd.exe as Administrator tool starts to run and then i received this message:
autorunner.bat exited on SERVER-HP with error code 0.
0
 
LVL 53

Expert Comment

by:McKnife
ID: 41831423
I cannot diagnose an unknown batch.
1
 

Author Comment

by:john lambert
ID: 41831427
team viewer please?
943 815 159
1264
0
 
LVL 53

Expert Comment

by:McKnife
ID: 41831428
At work I may not use teamviewer.
0
 

Author Comment

by:john lambert
ID: 41831430
someone says this: Error Code 0 means�The operation completed successfully.
0
 

Author Comment

by:john lambert
ID: 41831432
stackoverflow.com someone says: Error code 0 actually means success. This is psexec reporting that the remote execution completed successfully.
0
 

Author Comment

by:john lambert
ID: 41831434
.bat doesn't run what i do now?i run now?and when restart pc will run again automatically? :P
0
 
LVL 53

Expert Comment

by:McKnife
ID: 41831435
The error you see comes from psexec. Psexec has closed the "session" successfully after your batch has finished/exited/crashed.
0
 

Author Comment

by:john lambert
ID: 41831438
i see ....so other solution?when i open cmd.manually and run my autorunn.bat , runs fine! so my batch file is ok
0
 
LVL 53

Expert Comment

by:McKnife
ID: 41831442
You can run it... but can the system account run it? That is the question. You can simply verify by pasting one batch line after the other into a cmd window that you start as system. it will appear after you launch
psexec -s -i cmd
1
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:john lambert
ID: 41831444
as.jpg
0
 

Author Comment

by:john lambert
ID: 41831449
and now i run psexec and i got this:

as2.bmp
0
 

Author Comment

by:john lambert
ID: 41831474
not runs , i have 1 pc and 2 rdps i test all, no works
0
 
LVL 53

Expert Comment

by:McKnife
ID: 41831512
Sorry, what are you doing...
You should paste the lines of the batch into the command shell, one by one.
Instead, you start cmd through psexec and then you launch psexec again. You have not understood it.

On that 2nd command prompt that appears, you need to paste the contents of the batch file, line by line to see if the commands can be successfully run as system account.
0
 

Author Comment

by:john lambert
ID: 41831522
its a large .Bat file,there are 200 lines man,when u can come with team viewer?later?u can tell me when, plz is very very imp. for me to know if my administrator can run as system account, show me the way please, i know u can hep me
0
 

Author Comment

by:john lambert
ID: 41831566
+ i wanna run that .Bat as system. only ADMIN 1 not all administrators
0
 
LVL 53

Expert Comment

by:McKnife
ID: 41831603
Look, I cannot assist anywhere anytime just because someone say please pleeaase. You don't seem to understand that the system account is a different setup, for example it might not have access to the same ressources (network ressources for example) that your user has access to.
It should be simple to diagnose that, for you, too. So instead of asking me, do the work yourself, paste that code. You can paste all lines at once. Simply copy the whole batch code and right click the cmd-window. If nothing happens, you ned to activate copy and paste for the command line, first, it's called "quick edit" nd there's a checkbox to activate it right in the properties dialogue - that dialogue appears, when you rightclick the window title of the command shell and select "properties".
0
 

Author Comment

by:john lambert
ID: 41831827
i paste the entire code,everything seems ok
0
 

Author Comment

by:john lambert
ID: 41831829
i don't ask asistance becouse i am lazy etc...or ebcouse i say plz i ask help becouse my english is very very bad sometimes i don't understand what ur sayng..this is the only reason,thanks for everything anyway
0
 
LVL 53

Expert Comment

by:McKnife
ID: 41831889
So everything seems ok, all commands are carried out without problems? Then the batch should works as well. So again add a line that just calls the batch.
0
 

Author Comment

by:john lambert
ID: 41832270
1.I create a new folder on my desktop called: TEST (inside i paste PsExec.exe and PsExec64.exe)
  - my rdp is a x64

2.I run cmd.exe as Administrator and i paste this command:psexec -s -i cmd
  -now opens the 2'nd cmd window and there i follow psexec path:C:\Users\Ministr\Desktop\test
  then i paste all .bat content and i received this,this are the last lines:


The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
'ncrack.bookmark.txtECHO' is not recognized as an internal or external command,
operable program or batch file.
'ncrack.bookmark.txtSET' is not recognized as an internal or external command,
operable program or batch file.
'ncrack.bookmark.txtGOTO' is not recognized as an internal or external command,
operable program or batch file.


:END
ENDLOCAL
ECHO ON

C:\Users\Ministr\Desktop\test>@EXIT /B %errno%
1
 

Author Comment

by:john lambert
ID: 41832390
if i paste the line(syntax)from inside ''autorun.bat'' works fine,the command start running  but if i run autorun.bat doesn't work.I use a scanner ok?that scanner have a syntax,someone create a script to auto-save some important notes,that's why i run the entire batch,only for that,but if i use psexec syntax , cmd window start to run
0
 
LVL 53

Accepted Solution

by:
McKnife earned 500 total points
ID: 41832725
Sorry, the problem is not clear at all.
Neither why you want to run it as system, nor if or why it fails.

Please try to find someone to rephrase things for you. Best would be, to start small and learn how to redirect the output of your batch, so someone else can see what is happening. Teamviewer invitations through ee are not ok for the ee staff and will get deleted. I see this forum as knowledge sharing/knowledge exchange, not for doing things for other people that they themselves don't understand.

I don't think I can help you any further.
0
 

Author Closing Comment

by:john lambert
ID: 41859381
thanxxxx
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Learn about cloud computing and its benefits for small business owners.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now