 |
|
 |
Hello Xiangyang,
many thanks for your terrific program XYWinService!
I put it to use so that every 60 seconds, it starts a console app of my own that checks some variables and then fires up some windows programs.
So far it does work well, the win programs are starting and also seem to work (looking at the process explorer, they're taking resources at least , but I cannot bring up their user interfaces.
Using my console app alone, they show up perfectly well. It has to be the Service.
XYWinService is run on XP Pro SP3 as user (Admin group), so the environment shouldn't be a problem.
Can you help me, please?
Regards, Harry
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Xiangyang Liu
first off, thanks for this great little tool.
All works under XP. However, on Vista its not working. The log shows:
01/21/2009 14:08:13 351 Installing MyServName
01/21/2009 14:08:36 593 Error: The specified service does not exist as an installed service Source: Stack:
01/21/2009 14:08:36 609 Error: Service MyServName was not found on computer '.'. Source: System.ServiceProcess Stack: at System.ServiceProcess.ServiceController.GenerateNames() at System.ServiceProcess.ServiceController.get_ServiceName() at System.ServiceProcess.ServiceController.Start(String[] args) at XYWinService.XYWinService.Main(String[] pArgs)
So, it seems to me that the xyWinSevice -i is failing to install the MyServName into the service manager!?!?
I'm using an admin account to do this and UAC is disabled on the PC.
Any ideas on how to resolve this?
MAny thanks in advance
Pete
ps. for info the process part of the config xml file is:
<process> <filepath>C:\Program Files\Java\jdk1.6.0_02\bin\java.exe</filepath> <arguments>-jar jmstestclient.jar</arguments> <workingdir></workingdir> <restart>Yes</restart> </process>
modified on Wednesday, January 21, 2009 10:35 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Okay after some work I think I've got it.
In the source there's a line: oInfo.FileName = Environment.GetEnvironmentVariable("SystemRoot") + "\\Microsoft.NET\\Framework\\v2.0.50727\\InstallUtil.exe"; (ie hard coding the InstallUtil.exe) I'm running on an 64bit proc / OS and the InstallUtil at this location failed (when I tried it direct from the command line).
However, when I tried using the InstallUtil.exe from the "\\Microsoft.NET\\Framework64\\v2.0.50727\\InstallUtil.exe" direct from the command line it worked okay.
So I think I need to alter the source to determine if its a x64 proc or not & then alter the paths to the appropriate InstallUtil.exe file.
I'm off home now, will implement tomorrow.
Cheers
PEte
-------------------
I just changed the source to include this (in both the -i & -u case loops):
if (File.Exists(Environment.GetEnvironmentVariable("SystemRoot") + "\\Microsoft.NET\\Framework64\\v2.0.50727\\InstallUtil.exe")) { oInfo.FileName = Environment.GetEnvironmentVariable("SystemRoot") + "\\Microsoft.NET\\Framework64\\v2.0.50727\\InstallUtil.exe"; } else { oInfo.FileName = Environment.GetEnvironmentVariable("SystemRoot") + "\\Microsoft.NET\\Framework\\v2.0.50727\\InstallUtil.exe"; }
saves having to get proc info - if framework64 has been installed then I guess its a 64bit proc - dirty, but it works for me
modified on Friday, January 23, 2009 5:25 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new ServiceBase() }; ServicesToRun[0].ServiceName = ServiceName; ServicesToRun[0].AutoLog = false; ServiceBase.Run(ServicesToRun);
No service host code! Where is the OnStart() override? Am I missing anything?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, i have changed the xml to
<?xml version="1.0" encoding="utf-8" ?> - <Configuration> <ServiceName>GenerateFilesService</ServiceName> <ServiceDisplay>GenerateFilesService;/ServiceDisplay> <ServiceDescription>最酷的服务 (作者: 刘向阳)</ServiceDescription> <CheckProcessSeconds>30</CheckProcessSeconds> <RunAs>LocalSystem</RunAs> <PauseStart>1000</PauseStart> <PauseEnd>1000</PauseEnd> <LogFilePath /> - <Process> <FilePath>D:\Projects\Files\GenerateFilesServiceSetup\GenerateFilesServiceSetup\Debug\setup.exe</FilePath> <Arguments /> <WorkingDir>c:\windows\system32</WorkingDir> <Restart>Yes</Restart> </Process> </Configuration>
after running the exe it is asking for user name and password, what i shoul pass in it
pls rply soon
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I had an issue with the install of my services and it appears to be because the call to InstallUtil that passes the XYWinService.exe file location as an argument is not enclosed in talking marks. My XYWinService file was located in Program Files and the space causes a file not found error. I was able to run the InstallUtl command manually.
case "-i": case "/i": { WriteLog("Installing " + m_sServiceName); ProcessStartInfo oInfo = new ProcessStartInfo(); oInfo.FileName = Environment.GetEnvironmentVariable("SystemRoot") + "\\Microsoft.NET\\Framework\\v2.0.50727\\InstallUtil.exe"; oInfo.Arguments = m_sConfigFilePath.Replace(".xml", ".exe"); oInfo.CreateNoWindow = true; oInfo.UseShellExecute = false; Process.Start(oInfo); } break;
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
"You may have problems installing XYWinService on VISTA. This is because UAC is enabled, even if you logged on as admin, you don't have the proper privilege to install the service. You can either set up proper privileges (which is not easy) or disable UAC."
Why don't you add a manifest file that just tells Vista your application needs elevation? I consider it bad advice to suggest disabling UAC just because you as a developer don't know how to handle it. With a proper manifest file, the user does not need to set up or disable anything, is prompted for the required rights/credentials, and your application is still fine to be run as service. Take a look at this for a very nice introduction:
How-To-Tell-Vistas-UAC-What-Privelege-Level-Your-App-Requires[^]
In Visual Studio 2008 it's even easier - just add a manifest file and change the setting to fit your needs, done.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
kalme wrote: just because you as a developer don't know how to handle it
I know how to handle it. I just don't like it.
kalme wrote: I consider it bad advice to suggest disabling UAC
Why does every application has to be modified to ask for elevation in the first place? Is it so hard for VISTA to detect that a user is currently logged on as Admin and ask the user if he needs elevation for the program he is trying to run?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Xiangyang Liu ??? wrote: Why does every application has to be modified to ask for elevation in the first place? Is it so hard for VISTA to detect that a user is currently logged on as Admin and ask the user if he needs elevation for the program he is trying to run?
You mean like Vista asking for EVERY program the user starts, just because he's an admin? Wow, that would be even more annoying than UAC how it's built today... and what would you do with users who are not admins? Asked them too for EVERY program and let them provide admin credentials?
Btw. Vista indeed has built-in features to detect if a program needs elevation even if it does not provide a manifest. But this is targeted mainly at installers and does not work in your case. Obviously the long-term objective is to force developers think about their style of programming and make as much applications as possible to run without elevation. Of course there will always be the administrative tools that just need it (like your service), but that's no problem - as I said, you just need to tell Vista what you need.
Xiangyang Liu ??? wrote: I just don't like it.
Wow, that's... mature. Things are the way they are, and often things may not evolve in a way you like. Heck, I don't like a lot of Vista's new stuff too. But you just cannot blind yourself to the facts and force users of your software to do stupid things (yes, I consider turning off UAC stupid) just because you "don't like it". You always have to modify your applications when a new generation of OS's is released because some things don't work like before or have to be done different. But that's something I like about our jobs: being forced to develop yourself and never stop learning and adopting new techniques. Maybe you should too .
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
kalme wrote: You mean like Vista asking for EVERY program the user starts, just because he's an admin?
Ask only if it is needed. Most of the programs do not need elevation, right? So, if a program won't be able to run because lack of privilege, the OS should ask user if he is logged on as admin, as if the program is built with elevation mechanism. How is that more annoying?
kalme wrote: and what would you do with users who are not admins? Asked them too for EVERY program and let them provide admin credentials?
I did not say that. But for non-admin users, not allowing the programs to run is definitely less annoying, they won't be able to run many programs on XP today.
That said, new programs written for VISTA can still be built with mechanism to ask for elevation. Don't break other existing programs when there is no need to. Is that too much to ask (of Microsoft)?
kalme wrote: But you just cannot blind yourself to the facts and force users of your software to do stupid things (yes, I consider turning off UAC stupid) just because you "don't like it".
Stupidity is in the eyes of beholders. I don't think Microsoft is that sure about UAC either. Otherwise they won't let you turn it off so easily.
kalme wrote: But that's something I like about our jobs: being forced to develop yourself and never stop learning and adopting new techniques. Maybe you should too
Thank you for the advice. It is always good to see and hear from young optimists.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Xiangyang Liu ??? wrote: Don't break other existing programs when there is no need to.
Actually they tried hard not to (virtualization of file system, registry etc.), but your program is not an existing one, right? You made a new version, it's only natural to add features needed for newer OS's.
Xiangyang Liu ??? wrote: Thank you for the advice. It is always good to see and hear from young optimists.
You would be surprised to learn that I'm an "old fart" too . At least regarding programming business :P
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
kalme wrote: but your program is not an existing one, right? You made a new version, it's only natural to add features needed for newer OS's.
I am not talking about my programs only. For example, iisreset.exe won't work any more. The error message says you have to have admin privilege for it to work. I am the damn admin, can't it tell? After disabling UAC, it works. Sign.
kalme wrote: You would be surprised to learn that I'm an "old fart" too
It is equally good to see and hear from an old optimist, too (it is so rare to find one).
modified on Thursday, August 14, 2008 9:08 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Xiangyang Liu ??? wrote: For example, iisreset.exe won't work any more.
For these things I always have an administrator console at hand. Shortcut (you may already know that):
=> Windows key (to bring up the start menu) => "cmd.exe" (depending on your installed programs, "cmd" or even "cm" may be sufficient) => Press Ctrl+Shift+Enter
Oh and you can also choose to "elevate without prompting" in the Local Security Policy settings to make those annoying UAC messages go away without turning off UAC.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
kalme wrote: For these things I always have an administrator console at hand. Shortcut (you may already know that):
=> Windows key (to bring up the start menu) => "cmd.exe" (depending on your installed programs, "cmd" or even "cm" may be sufficient) => Press Ctrl+Shift+Enter
I don't. I will try it. If I can install XYWinService this way, then it is a much better solution than modifying each program to work with UAC. Thanks.
kalme wrote: Oh and you can also choose to "elevate without prompting" in the Local Security Policy settings to make those annoying UAC messages go away without turning off UAC.
That is close, if not same, to disabling UAC for one or more users, right?
modified on Friday, August 15, 2008 7:29 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi again!
Xiangyang Liu ??? wrote: That is close, if not same, to disabling UAC for one or more users, right? [Big Grin]
Not really. I agree it's a security risk to do that (they also say so in the description by the way), but it's quite a difference if your account always has the administrator token attached and any malicious software and/or security flaw can do any harm to your system (UAC disabled) or if malicious software has to be aware of UAC and try to find its way around it, right? For example, the latter handles any security flaws exploitable in previous Windows versions like XP.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Thanks, Ravi. There are guys/girls in my office that make me feel like a grandpa, I am glad that I can still be useful sometimes. BTW, I looked at your profile picture today, you haven't aged a bit after these years.
modified on Friday, August 8, 2008 6:21 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Xiangyang Liu ??? wrote: you haven't aged a bit after these years.
All that coding keeps us old farts looking young. 
/ravi
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I wish you had done this 6 months ago, when I went through the pain of making my server run as a service, which required some help from the fellow who wrote NetZ. 
Marc
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Sorry, 6 months ago I hated everything related to VISTA, I just concluded that VISTA is not that bad, at least it is something I can live with.
modified on Thursday, August 7, 2008 9:05 PM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Really nice, this project helped me to convert my little server application to a service within a day! Thx a lot!
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |