I created my custom powershell cmdlet. It registers and installs fine, but when I try to uninstall it, I get an error. I use this command to uninstall it:
c:\windows\microsoft.net\framework64\v4.0.30319\installutil /u 'path to .dll'
Error: The uninstall is beginning. See the contents of the log file
for the 'path to .dll' assembly's progress. The file is located at
'path to log of installer'.InstallLog. Uninstalling assembly 'path to
.dll'. Affected parameters are: logtoconsole = assemblypath =
'path to .dll' logfile = 'install log path'.InstallLog An exception
occurred during the uninstallation of the 'name of my installer'
installer. System.ArgumentException: Cannot delete a subkey tree
because the subkey does not exist. An exception occurred while
uninstalling. This exception will be ignored and the uninstall will
continue. However, the application might not be fully uninstalled
after the uninstall is complete.
The uninstall has completed. An exception occurred while uninstalling.
This exception will be ignored and the uninstall will continue.
However, the application might not be fully uninstalled after the
uninstall is complete.
I looked at the registry. while I found few references to my cmdlet, removing them doesn't make a difference.
I currently uninstall by manually deleting the path that the installer of the cmdlet resides at. I'm not sure if this OK and wouldn't lead to problems in the future.
Do you have an idea on how fix this?
Related
I have developed a windows service in c#, The project works fine in DEBUG mode, also the project is built with out any errors. When I try to install the service using InstallUtil.exe, I get below error and the service is not installed. Could someone please help what is going wrong here.
Installation command
Open command prompt in admin mode
Navigate to C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
Run below command
installutil.exe C:\Users\Public\TestService\MyService\bin\Release\MyService.exe
Error
Creating EventLog source MyService in log Application...
An exception occurred during the Install phase.
System.Exception: Value cannot be null.
Parameter name: path1
Below is the complete installation log.
Microsoft (R) .NET Framework Installation utility Version 4.8.4161.0
Copyright (C) Microsoft Corporation. All rights reserved.
Running a transacted installation.
Beginning the Install phase of the installation.
See the contents of the log file for the C:\Users\Public\TestService\MyService\bin\Release\MyService.exe assembly's progress.
The file is located at C:\Users\Public\TestService\MyService\bin\Release\MyService.InstallLog.
Installing assembly 'C:\Users\Public\TestService\MyService\bin\Release\MyService.exe'.
Affected parameters are:
logtoconsole =
assemblypath = C:\Users\Public\TestService\MyService\bin\Release\MyService.exe
logfile = C:\Users\Public\TestService\MyService\bin\Release\MyService.InstallLog
Installing service MyService...
Service MyService has been successfully installed.
Creating EventLog source MyService in log Application...
An exception occurred during the Install phase.
System.Exception: Value cannot be null.
Parameter name: path1
The Rollback phase of the installation is beginning.
See the contents of the log file for the C:\Users\Public\TestService\MyService\bin\Release\MyService.exe assembly's progress.
The file is located at C:\Users\Public\TestService\MyService\bin\Release\MyService.InstallLog.
Rolling back assembly 'C:\Users\Public\TestService\MyService\bin\Release\MyService.exe'.
Affected parameters are:
logtoconsole =
assemblypath = C:\Users\Public\TestService\MyService\bin\Release\MyService.exe
logfile = C:\Users\Public\TestService\MyService\bin\Release\MyService.InstallLog
Restoring event log to previous state for source MyService.
Service MyService is being removed from the system...
Service MyService was successfully removed from the system.
Attempt to stop service MyService.
The Rollback phase completed successfully.
The transacted install has completed.
The installation failed, and the rollback has been performed.
did you try to go into your path : C:\Users\Public\TestService\MyService\bin\Release (if you built in debug use the debug folder)
and here, use command : installutil MyService.exe
You said the projet work well in debug mode. can you install it in debug ?
So I am trying to create a service using C# in Visual Studio 2017 and I keep getting an error when I try to install it.
Right now, I don't even have anything in my service, I just want to be able to install the service. I created a new Project in Visual Studio 2017 using the Windows Service (.NET Framework) template under Visual C# > Windows Desktop. I then added the installer via Right Click > Add Installer. For serviceProcessInstaller1, I set the account to LocalSystem. And...that's it!
Now, I try to install it. I open up command prompt (run as administrator) and I do
InstallUtil ServiceTest.exe
Things start off smoothly, but then I get a message:
"An exception occured during the Install phase.
System.UnauthorizedAccessException: Attempted to perform an
unauthorized operation."
What could be generating this message?
I've googled and tried the following things:
Ensure I run command prompt as administrator.
Assign Full Control to
the project folder to my admin account.
Configure permissions to Full
Control for admin account in the security log of regedit.
Log into my
computer as an administrator (rather than regular user) and run it
that way.
Despite these things, I keep getting the same error. What else could I be doing wrong? Would really appreciate some advice!
Note: I am trying to install this service locally on my computer.
Edit: Per request, here are the logs. I named my project "FailedService", by the way, since I can't get it to work!
InstallUtil.InstallLog
Running a transacted installation.
Beginning the Install phase of the installation.
See the contents of the log file for the C:\Users\first.m.last\source\repos\FailedService\FailedService\bin\Debug\FailedService.exe assembly's progress.
The file is located at C:\Users\first.m.last\source\repos\FailedService\FailedService\bin\Debug\FailedService.InstallLog.
An exception occurred during the Install phase.
System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.
The Rollback phase of the installation is beginning.
See the contents of the log file for the C:\Users\first.m.last\source\repos\FailedService\FailedService\bin\Debug\FailedService.exe assembly's progress.
The file is located at C:\Users\first.m.last\source\repos\FailedService\FailedService\bin\Debug\FailedService.InstallLog.
The Rollback phase completed successfully.
The transacted install has completed.
FailedService.InstallLog
Installing assembly 'C:\Users\first.m.last\source\repos\FailedService\FailedService\bin\Debug\FailedService.exe'.
Affected parameters are:
logtoconsole =
logfile = C:\Users\first.m.last\source\repos\FailedService\FailedService\bin\Debug\FailedService.InstallLog
assemblypath = C:\Users\first.m.last\source\repos\FailedService\FailedService\bin\Debug\FailedService.exe
Installing service Service1...
Creating EventLog source Service1 in log Application...
Rolling back assembly 'C:\Users\first.m.last\source\repos\FailedService\FailedService\bin\Debug\FailedService.exe'.
Affected parameters are:
logtoconsole =
logfile = C:\Users\first.m.last\source\repos\FailedService\FailedService\bin\Debug\FailedService.InstallLog
assemblypath = C:\Users\first.m.last\source\repos\FailedService\FailedService\bin\Debug\FailedService.exe
Restoring event log to previous state for source Service1.
I was FINALLY able to resolve this issue. I was able to get to the bottom of it by using SysInternal's Process Monitor. I opened up the program and had it take logs for InstallUtil.exe. From there, I began to search for any logs that said "Access Denied". As I sorted through them, I noticed something interesting: it was trying to create a registry key, but it kept failing!
So I went into the registry and created a key named "ServiceTest". After that, I ran the InstallUtil command again, and it worked!
If anyone else is having trouble, the solution is to create a key named after your process name in the following location:
HKLM\System\CurrentControlSet\Services\EventLog\Application\
Enter the full path to installUtil & your service binary in an elevated prompt, that could do.
The program is executing properly without any error in Debug configuration But in Release configuration it throws an error.
The "ParseILMergeInfoTask" task failed unexpectedly.
System.Exception: File 'SharedAssemblyILMergeInfoFilePath' passed to argument 'x86\ret\SharedAssemblyILMergeInfo.csv' does not exist.
at Microsoft.Build.ILTasks.ParseILMergeInfoTask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
I can't run any program in Release configuration. It throws the same error.
Update
I think I found the problem but I don't know to resolve it. Previously I had an error Unable to load package 'Microsoft.Net.Native.SharedLibrary-x64'. To resolve it I follow it this answer. So I installed Microsoft.Net.Native.SharedLibrary-x64.1.6.1, Microsoft.Net.Native.SharedLibrary-x86.1.6.1 and Microsoft.Net.Native.SharedLibrary-arm.1.6.1 manually. Now If I open Microsoft.Net.Native.SharedLibrary-x64 package folder I can't find build and tools folder within it.
It is a problem due to the Internet connection.
Just delete the package
C:\Users\ponvi\.nuget\packages\microsoft.net.native.sharedlibrary-x64
Download the package using Mobile Data.
Another answer by rubStackOverflow
Really strange issue, in my case, I had to change my default network
DNS(network card) from 8.8.8.8 to 208.67.222.222.
I am trying to Install a windows service I made with the following command :
C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug>InstallU
til.exe filechecker.exe
but I am getting the following message:
Running a transacted installation.
Beginning the Install phase of the installation.
See the contents of the log file for the C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.exe assembly's progress.
The file is located at C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.InstallLog.
An exception occurred during the Install phase.
System.ArgumentException: Must specify value for source.
The Rollback phase of the installation is beginning.
See the contents of the log file for the C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.exe assembly's progress.
The file is located at C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.InstallLog.
The Rollback phase completed successfully.
The transacted install has completed.
Running a transacted installation.
Beginning the Install phase of the installation.
See the contents of the log file for the C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.exe assembly's progress.
The file is located at C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.InstallLog.
An exception occurred during the Install phase.
System.ArgumentException: Must specify value for source.
The Rollback phase of the installation is beginning.
See the contents of the log file for the C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.exe assembly's progress.
The file is located at C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.InstallLog.
The Rollback phase completed successfully.
The transacted install has completed.
How can I solve this issue?
A ServiceInstaller always1 creates an event log source, and sets the Source name to the ServiceName. The error suggests to me that you're not setting the ServiceName on your ServiceInstaller instance (although I'd have hoped for a better error).
1Unless you manually iterate its installers collection and remove it, after it's instantiated. You'd also have to make sure you turn off all of the automatic logging and/or manually add your own EventLogInstaller using the same source name - this can be useful if you wish all logging from the service (including automatic logging) to go to somewhere other than the Application event log.
I need to uninstall a Windows Service I have created, but I get this error using the "Uninstall or change program" program in windows:
Error. An exception occurred while
uninstalling. This exception will be
ignored and the uninstall will
continue. However, the application
might not be fully uninstalled after
the uninstall is complete. -> The
event log source '111 My Service'
cannot be deleted, because it's equal
to the log name.
Then I click "OK" and the program remains listed in the list of installed programs. What is worse, I cannot install a new version of it. The windows installer says that another version of this product is already installed and I should uninstall it first. How do I get rid of this program?
Update Here is what is happening when I run InstallUtil.exe /u command on it.
The uninstall is beginning. See the
contents of the log file for the
C:\MyService.MyService. assembly's progress. The file
is located at
C:\MyService.MyService.InstallLog.
Uninstalling assembly
'C:\MyService.MyService.exe'. Affected
parameters are: logtoconsole =
assemblypath = C:\MyService.exe
logfile =
C:\MyService.MyService.InstallLog
Removing EventLog source 111 My
Service. An exception occurred during
the uninstallation of the
System.Diagnostics.EventLogInstaller
installer.
System.InvalidOperationException: The
event log source '111 My Service'
cannot be deleted, because it's equal
to the log name. An exception occurred
while uninstalling. This exception
will be ignored and the uninstall will
continue. However, the application
might not be fully uninstalle l is
complete.
The uninstall has completed. An
exception occurred while uninstalling.
This exception will be ignored and the
uninstall will continue. However, the
application might not be fully
uninstalle l is complete.
Try to execute next command in cmd:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /u "c:\myservice.exe"
The second option is:
sc delete <service name>
After running the line above you can try to remove the service branch as well in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.
The accepted answer didn't work for me.
What worked is open regedit in administrator mode and find the service and delete it.
I had the exact same problem (and nothing in the selected answer worked).
Surprisingly, what fixed the problem was (using the standard "Uninstall or change program" or "Programs and Features" windows dialog) right-clicking on the program and choosing repair (this was apparently successful), and then uninstalling.
This just happened to me and the solution above didn't work where you run the InstallUtil.exe or delete the service. I had initially set up my service with the "LocalSystem" security context, and it was installed with that. I later changed the security context to "User" and recompiled the service executable and tried to uninstall the old service. The error messages were coming up that are described here, and once I went and changed the security context back to "LocalSystem" I could fully uninstall.
In other words, you might want to uninstall your old service with the executable it was created with rather than a newer one with possible modifications.