Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 429
  • Last Modified:

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

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
john lambert
Asked:
john lambert
  • 17
  • 10
1 Solution
 
McKnifeCommented:
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
 
john lambertAuthor Commented:
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
 
McKnifeCommented:
It does not seem to be the correct path. double check.
1
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
john lambertAuthor Commented:
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
 
McKnifeCommented:
I cannot diagnose an unknown batch.
1
 
john lambertAuthor Commented:
team viewer please?
943 815 159
1264
0
 
McKnifeCommented:
At work I may not use teamviewer.
0
 
john lambertAuthor Commented:
someone says this: Error Code 0 means�The operation completed successfully.
0
 
john lambertAuthor Commented:
stackoverflow.com someone says: Error code 0 actually means success. This is psexec reporting that the remote execution completed successfully.
0
 
john lambertAuthor Commented:
.bat doesn't run what i do now?i run now?and when restart pc will run again automatically? :P
0
 
McKnifeCommented:
The error you see comes from psexec. Psexec has closed the "session" successfully after your batch has finished/exited/crashed.
0
 
john lambertAuthor Commented:
i see ....so other solution?when i open cmd.manually and run my autorunn.bat , runs fine! so my batch file is ok
0
 
McKnifeCommented:
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
 
john lambertAuthor Commented:
as.jpg
0
 
john lambertAuthor Commented:
and now i run psexec and i got this:

as2.bmp
0
 
john lambertAuthor Commented:
not runs , i have 1 pc and 2 rdps i test all, no works
0
 
McKnifeCommented:
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
 
john lambertAuthor Commented:
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
 
john lambertAuthor Commented:
+ i wanna run that .Bat as system. only ADMIN 1 not all administrators
0
 
McKnifeCommented:
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
 
john lambertAuthor Commented:
i paste the entire code,everything seems ok
0
 
john lambertAuthor Commented:
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
 
McKnifeCommented:
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
 
john lambertAuthor Commented:
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
 
john lambertAuthor Commented:
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
 
McKnifeCommented:
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
 
john lambertAuthor Commented:
thanxxxx
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 17
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now