{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/31842","repository_url":"https://api.github.com/repos/dotnet/corefx","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/31842/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/31842/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/31842/events","html_url":"https://github.com/dotnet/corefx/issues/31842","id":352022712,"node_id":"MDU6SXNzdWUzNTIwMjI3MTI=","number":31842,"title":"Bug with RunAs on Windows","user":{"login":"sirkadirov","id":7001431,"node_id":"MDQ6VXNlcjcwMDE0MzE=","avatar_url":"https://avatars3.githubusercontent.com/u/7001431?v=4","gravatar_id":"","url":"https://api.github.com/users/sirkadirov","html_url":"https://github.com/sirkadirov","followers_url":"https://api.github.com/users/sirkadirov/followers","following_url":"https://api.github.com/users/sirkadirov/following{/other_user}","gists_url":"https://api.github.com/users/sirkadirov/gists{/gist_id}","starred_url":"https://api.github.com/users/sirkadirov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirkadirov/subscriptions","organizations_url":"https://api.github.com/users/sirkadirov/orgs","repos_url":"https://api.github.com/users/sirkadirov/repos","events_url":"https://api.github.com/users/sirkadirov/events{/privacy}","received_events_url":"https://api.github.com/users/sirkadirov/received_events","type":"User","site_admin":false},"labels":[{"id":247536927,"node_id":"MDU6TGFiZWwyNDc1MzY5Mjc=","url":"https://api.github.com/repos/dotnet/corefx/labels/area-System.Diagnostics.Process","name":"area-System.Diagnostics.Process","color":"d4c5f9","default":false},{"id":309869280,"node_id":"MDU6TGFiZWwzMDk4NjkyODA=","url":"https://api.github.com/repos/dotnet/corefx/labels/question","name":"question","color":"207de5","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-20T07:52:52Z","updated_at":"2018-08-21T17:41:58Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"**Hello!** About a year ago I found a \"bug in .NET Framework\": when I run repro (given with this issue, for example) with Windows Task Scheduler (or any other service, maybe program), process `proc` won't return any output.\r\n\r\nWhen I recently moved to .NET Core, I noticed that this \"error\" returned. Not tested on Linux, maybe this is Windows-specific problem. And 99% not .NET Core bug.\r\n\r\nIt's not a bug with my code. More information in next sections.\r\n\r\n## Task Scheduler config file\r\nStart program on power on, as another user (not on log on), as Administrator, etc.\r\n````xml\r\n<?xml version=\"1.0\" encoding=\"UTF-16\"?>\r\n<Task version=\"1.4\" xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\r\n  <RegistrationInfo>\r\n    <Date>2017-08-02T10:51:29.2789696</Date>\r\n    <Author>SIRKADIROVSERVE\\Administrator</Author>\r\n    <URI>\\SimplePM\\SimplePM_Server</URI>\r\n  </RegistrationInfo>\r\n  <Triggers>\r\n    <BootTrigger>\r\n      <Enabled>true</Enabled>\r\n    </BootTrigger>\r\n  </Triggers>\r\n  <Principals>\r\n    <Principal id=\"Author\">\r\n      <UserId>S-1-5-18</UserId>\r\n      <RunLevel>HighestAvailable</RunLevel>\r\n    </Principal>\r\n  </Principals>\r\n  <Settings>\r\n    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>\r\n    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>\r\n    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>\r\n    <AllowHardTerminate>false</AllowHardTerminate>\r\n    <StartWhenAvailable>true</StartWhenAvailable>\r\n    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>\r\n    <IdleSettings>\r\n      <StopOnIdleEnd>true</StopOnIdleEnd>\r\n      <RestartOnIdle>false</RestartOnIdle>\r\n    </IdleSettings>\r\n    <AllowStartOnDemand>true</AllowStartOnDemand>\r\n    <!-- Yes, now disabled -->\r\n    <Enabled>false</Enabled>\r\n    <Hidden>false</Hidden>\r\n    <RunOnlyIfIdle>false</RunOnlyIfIdle>\r\n    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>\r\n    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>\r\n    <WakeToRun>true</WakeToRun>\r\n    <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>\r\n    <Priority>7</Priority>\r\n    <RestartOnFailure>\r\n      <Interval>PT1M</Interval>\r\n      <Count>10</Count>\r\n    </RestartOnFailure>\r\n  </Settings>\r\n  <Actions Context=\"Author\">\r\n    <Exec>\r\n      <Command>dotnet</Command>\r\n      <Arguments>ConsoleApp1.dll</Arguments>\r\n      <WorkingDirectory>C:\\Users\\Administrator\\RiderProjects\\Solution1\\ConsoleApp1\\bin\\Debug\\netcoreapp2.1</WorkingDirectory>\r\n    </Exec>\r\n  </Actions>\r\n</Task>\r\n````\r\n\r\n## Repro\r\n````c#\r\nusing System;\r\nusing System.Diagnostics;\r\nusing System.IO;\r\nusing System.Security;\r\nusing System.Text;\r\n\r\nnamespace ConsoleApp1\r\n{\r\n    \r\n    class Program\r\n    {\r\n        \r\n        private ProcessStartInfo programStartInfo = new ProcessStartInfo\r\n        {\r\n\r\n            RedirectStandardOutput = true,\r\n            RedirectStandardError = true,\r\n            RedirectStandardInput = true,\r\n\r\n            StandardOutputEncoding = Encoding.UTF8,\r\n            StandardErrorEncoding  = Encoding.UTF8,\r\n            \r\n            UseShellExecute = false,\r\n            LoadUserProfile = false,\r\n            CreateNoWindow = true,\r\n            WindowStyle = ProcessWindowStyle.Hidden,\r\n            ErrorDialog = false,\r\n\r\n            // Feel free to change this, repro will work\r\n            Arguments = \"/K echo %username%\",\r\n            FileName = \"cmd.exe\",\r\n            WorkingDirectory = \"C:\\\\Windows\\\\System32\\\\\"\r\n            \r\n        };\r\n\r\n        public static void Main(string[] args)\r\n        {\r\n            \r\n            new Program().Run();\r\n            \r\n        }\r\n        \r\n        void Run()\r\n        {\r\n            \r\n            var proc = new Process{\r\n\r\n                StartInfo = programStartInfo,\r\n                EnableRaisingEvents = true,\r\n\r\n            };\r\n            \r\n            proc.StartInfo.UserName = \"SimplePM_StartUser\";\r\n\r\n            proc.StartInfo.LoadUserProfile = true;\r\n\r\n            var encPassword = new SecureString();\r\n\r\n            foreach (var c in \"1234567890\")\r\n                encPassword.AppendChar(c);\r\n\r\n            proc.StartInfo.Password = encPassword;\r\n\r\n            proc.OutputDataReceived += proc_OutputDataReceived;\r\n\r\n            proc.Start();\r\n\r\n            proc.BeginOutputReadLine();\r\n\r\n            if (!proc.WaitForExit(5000))\r\n            {\r\n\r\n                try\r\n                {\r\n                    proc.Kill();\r\n                }\r\n                catch { }\r\n\r\n            }\r\n            \r\n        }\r\n        \r\n        private void proc_OutputDataReceived(object sender, DataReceivedEventArgs e)\r\n        {\r\n\r\n            if (e.Data == null)\r\n                return;\r\n\r\n            File.AppendAllText(\"E:\\\\1.txt\", e.Data.TrimEnd());\r\n            \r\n            Console.WriteLine(e.Data.TrimEnd());\r\n\r\n        }\r\n        \r\n    }\r\n    \r\n}\r\n````\r\n\r\n## Environment\r\n````\r\nOS: Microsoft Windows Server 2016 Standard (GUI)\r\nFramework: .NET Framework (latest), .NET Core (latest)\r\nHardware-specific: I don't think\r\n````\r\n\r\nCan anyone help me with this problem?\r\n**Thanks for reading!**\r\n\r\n## Non-.NET Core issue\r\nFreely close it, because it's not .NET Core (maybe).\r\n\r\n**P.S. Sorry for my bad English, it's not my main language.**"},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/414760384","html_url":"https://github.com/dotnet/corefx/issues/31842#issuecomment-414760384","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/31842","id":414760384,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDc2MDM4NA==","user":{"login":"krwq","id":660048,"node_id":"MDQ6VXNlcjY2MDA0OA==","avatar_url":"https://avatars1.githubusercontent.com/u/660048?v=4","gravatar_id":"","url":"https://api.github.com/users/krwq","html_url":"https://github.com/krwq","followers_url":"https://api.github.com/users/krwq/followers","following_url":"https://api.github.com/users/krwq/following{/other_user}","gists_url":"https://api.github.com/users/krwq/gists{/gist_id}","starred_url":"https://api.github.com/users/krwq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krwq/subscriptions","organizations_url":"https://api.github.com/users/krwq/orgs","repos_url":"https://api.github.com/users/krwq/repos","events_url":"https://api.github.com/users/krwq/events{/privacy}","received_events_url":"https://api.github.com/users/krwq/received_events","type":"User","site_admin":false},"created_at":"2018-08-21T17:41:58Z","updated_at":"2018-08-21T17:41:58Z","author_association":"MEMBER","body":"@sirkadirov is it possible that your problem is related to `cmd /k`?\r\nper cmd help:\r\n\r\n```\r\n/C      Carries out the command specified by string and then terminates\r\n/K      Carries out the command specified by string but remains\r\n```\r\n\r\n`/C` is the one you might want to use as `/k` spawns new command prompt.\r\nI'd recommend to run exactly what you did above in the command prompt and see if you can see output. If you can see the output in the command line (not newly created command prompt, the same one you run it in) then this might be a bug in .NET."}}
{"actor":{"display_login":"krwq"}}