<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Task Scheduler | KC's Blog</title>
	<atom:link href="https://www.kjctech.net/tag/task-scheduler/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.kjctech.net</link>
	<description></description>
	<lastBuildDate>Tue, 24 Jan 2023 18:21:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i0.wp.com/www.kjctech.net/wp-content/uploads/2016/12/cropped-KC-Logo.png?fit=32%2C32&#038;ssl=1</url>
	<title>Task Scheduler | KC's Blog</title>
	<link>https://www.kjctech.net</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">24634607</site>	<item>
		<title>Why my scheduled task completes with return code 2</title>
		<link>https://www.kjctech.net/why-my-scheduled-task-completes-with-return-code-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=why-my-scheduled-task-completes-with-return-code-2</link>
					<comments>https://www.kjctech.net/why-my-scheduled-task-completes-with-return-code-2/#comments</comments>
		
		<dc:creator><![CDATA[Kent Chen]]></dc:creator>
		<pubDate>Mon, 30 Jan 2012 19:27:05 +0000</pubDate>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Task Scheduler]]></category>
		<guid isPermaLink="false">http://www.kjctech.net/?p=1667</guid>

					<description><![CDATA[<p>I recently had a task job scheduled in one of Windows server 2008 but kept getting a return code 2 every time it runs. Task Scheduler successfully completed task &#34;\RoomView&#34; , instance &#34;{fcc8337a-11b2-4e69-b101-a58bb8d18ead}&#34; , action &#34;C:\Windows\SYSTEM32\cmd.exe&#34; with return code 2. Obviously, even though it says Task Scheduler successfully completed task, the task didn&#8217;t complete what it supposed to do. The [&#8230;]</p>
The post <a href="https://www.kjctech.net/why-my-scheduled-task-completes-with-return-code-2/">Why my scheduled task completes with return code 2</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>I recently had a task job scheduled in one of Windows server 2008 but kept getting a return code 2 every time it runs.</p>
<blockquote>
<p>Task Scheduler successfully completed task &quot;\RoomView&quot; , instance &quot;{fcc8337a-11b2-4e69-b101-a58bb8d18ead}&quot; , action &quot;C:\Windows\SYSTEM32\cmd.exe&quot; with return code 2.</p>
</blockquote>
<p>Obviously, even though it says Task Scheduler successfully completed task, the task didn&#8217;t complete what it supposed to do.</p>
<p>The return code 2, as part of <a href="http://www.febooti.com/products/automation-workshop/online-help/events/run-dos-cmd-command/exit-codes/" target="_blank" rel="noopener">the cmd command exit code</a>, indicates that <em>The system cannot find the file specified, meaning that the file in task cannot be found in specified location.</em></p>
<p>It doesn&#8217;t seem to be the case in the task I&#8217;ve scheduled. I had made sure all files are in the location where it belongs. And I can run the task manually outside the task scheduler. The only explanation why the scheduler threw this exit code is probably the security setting. Since I already set the task run under the admin account, I enforced it to run with the highest privileges, the option under General tab in task properties, just like <em>Run as administrator.</em></p>
<p><img data-recalc-dims="1" fetchpriority="high" decoding="async" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2012/01/image6.png?resize=580%2C432" width="580" height="432" /></p>
<p>And bingo, now I am finally getting 0 as the return code now, stating that program successfully completed.</p>
<p><img data-recalc-dims="1" decoding="async" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://i0.wp.com/www.kjctech.net/wp-content/uploads/2012/01/image7.png?resize=580%2C404" width="580" height="404" /></p>The post <a href="https://www.kjctech.net/why-my-scheduled-task-completes-with-return-code-2/">Why my scheduled task completes with return code 2</a> first appeared on <a href="https://www.kjctech.net">KC's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://www.kjctech.net/why-my-scheduled-task-completes-with-return-code-2/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1667</post-id>	</item>
	</channel>
</rss>
