Windows 서비스 zip 파일을 다운로드하고 추출하는 이름이 MyCustomUpdater.exe 인 프로그램이 하나 있습니다.C# (바탕 화면 응용 프로그램)에서 Windows 서비스를 설치하는 방법
추출 폴더 내가
내가 그것을
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.Verb = "runas";
process.Start();
if (process != null)
{
process.StandardInput.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.Windows) + "\\Microsoft.NET\\Framework\\v4.0.30319\\installutil.exe /u \"" + "E:\Testing\MV.AutoUpdateWindowsService.exe" + "\"");
process.StandardInput.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.Windows) + "\\Microsoft.NET\\Framework\\v4.0.30319\\installutil.exe \"" + "E:\Testing\MV.AutoUpdateWindowsService.exe" + "\"");
process.StandardInput.Close();
}
process.Close();
에 대한 노호 언급 코드를 사용 MyCustomUpdater.exe
에서 해당 MyWindowsServices.exe를 설치하려는 MyWindowsServices.exe이를 제출해야하지만 설치하지 않습니다 Windows 서비스
이 코드는 하나의 빈 검은 색 명령 프롬프트 창을 엽니 다. 더 이상의 실행.
또한 2013
내 MyCustomUpdater.exe 에 대한 파일을 app.manifest 추가 내가 비주얼 스튜디오와 닷넷 프레임 워크 4.5을 사용
process.StartInfo.Arguments
에서 Windows 서비스 설치 명령을 실행하려고 app.manifest를 포함시킨 후 설정했습니다. 오른쪽> 매니페스트가 나는 확률 코드 후 app.manifest 을 를 [드롭 다운을 클릭]를 선택 프로그램> 부동산> 응용 프로그램> 자원을 클릭
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\Microsoft.NET\Framework\v4.0.30319\installutil.exe", _FilePath);
이 제거 프로세스
에 대해 잘 작동하지만,Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\Microsoft.NET\Framework\v4.0.30319\installutil.exe", "/u " + _FilePath);
또는
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\Microsoft.NET\Framework\v4.0.30319\installutil.exe" + " /u ", _FilePath);
작동하지
가 우는 소리는
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<PermissionSet Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
</application>
</compatibility>
</asmv1:assembly>
가 도와 app.manifest 파일의 코드입니다.
감사
안녕하세요. installutil.exe를 직접 실행하지 않고 (즉,'StartInfo.FileName'에서) 표준 입력을 사용하여'cmd.exe'에 exe를 전달할 이유가 있습니까? – Rob
'process.OutputDataReceived + = (s, e) => _ILog.Fatal (@ "OutputDataReceived :"+ e.Data); '을 추가했지만 출력을 얻을 수 없음 –
어떻게 실패합니까? InstallUtil.InstallLog 파일에 단서가 있습니까? – Rob