<?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>marius &#187; schtasks</title>
	<atom:link href="http://devilx.net/tag/schtasks/feed/" rel="self" type="application/rss+xml" />
	<link>http://devilx.net</link>
	<description></description>
	<lastBuildDate>Mon, 14 May 2012 21:25:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Windows (XP) and Sysprep.exe</title>
		<link>http://devilx.net/2008/11/29/windows-xp-and-sysprepexe/</link>
		<comments>http://devilx.net/2008/11/29/windows-xp-and-sysprepexe/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 17:07:34 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Life itself]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[DOS]]></category>
		<category><![CDATA[Firewall]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Job]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[netsh]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[RDP]]></category>
		<category><![CDATA[reg]]></category>
		<category><![CDATA[Registry]]></category>
		<category><![CDATA[schtasks]]></category>
		<category><![CDATA[strace]]></category>
		<category><![CDATA[Sysprep]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[XP]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=640</guid>
		<description><![CDATA[Last week, I was helping-out on Thomas&#8217; project at work, where I had to implement some stuff regarding Windows XP Mini-Setup with Sysprep.exe. He built an image which automatically started the mini-setup on the machine&#8217;s first boot and configured every &#8230; <a href="http://devilx.net/2008/11/29/windows-xp-and-sysprepexe/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Last week, I was helping-out on Thomas&#8217; project at work, where I had to implement some stuff regarding Windows XP Mini-Setup with Sysprep.exe. He built an image which automatically started the mini-setup on the machine&#8217;s first boot and configured every parameter of the operating system the way he needed it. My job has been to check whether it&#8217;s possible to make the mini-setup run a custom script at its end and if possible activate RDP, open the firewall&#8217;s RDP port and add a domain group to the RDP-users.</p>
<p>The first two things weren&#8217;t that hard to realize. Sysprep actually runs every command contained in the <em>Cmdlines.txt</em> in <em>\%sysprep%\i386\$oem$\</em> directory. Enabling RDP is possible using a simple <strong>reg</strong>-commandline which changes the value of the <em>fDenyTSConnection</em> key. Also opening the firewall&#8217;s port is trivial by using the <strong>netsh</strong> command. There seems to be some way by using a <em>winnt.sif</em>-file containing some parameters that should modify the firewall setup, unfortunately I didn&#8217;t manage to get that working in an reasonable amount of time. So I&#8217;ve just used the mentioned command to open the port in the firewall, for all profiles. The profile-argument is important, for me it did not work out without setting it to <em>ALL</em>.</p>
<p>Anyhow, the third ToDo was (and still is) tricky. The problem when using the <strong>net</strong> <em>localgroup</em> command to add the group to the local <em>Remotedesktopusers</em>-group is the following: While the mini-setup is running, the computer hasn&#8217;t got its future hostname and because of that it&#8217;s not yet joined to the domain. When trying to execute the net command for adding the domain-group to the local group it will of course fail. I searched for many different ways to do that, but each method I&#8217;ve found didn&#8217;t really work out for me:</p>
<p>autoexec.bat: Hacking the command to the autoexec.bat, so that it gets executed on the next reboot would be a way, unfortunately this file is ignore by every not-DOS-based Windows, like Windows XP is, for example.</p>
<p>win.ini: I&#8217;m not sure exactly why this didn&#8217;t work out, because the documentation says, that the Run-parameters configured in that INI will be run on Windows&#8217; startup. In my case, the net command hasn&#8217;t seemed to be run. I think that the win.ini commands get executed before the connection to the domain has been established, so that the actual net command would have been run, but unsuccessful.</p>
<p>Run/RunOnce/RunService/RunServiceOnce-Keys: Would work out pretty good, if some user would log in. In my case, no user will log in until RDP is available to the specific domain-group.</p>
<p>And so on. I got pretty desperate, until I got an idea: A scheduled task! Windows supports adding scheduled tasks even from the commandline by using the <strong>schtasks</strong> command. I tried out the <em>/sc onboot</em> parameter, but unfortunately it seems to be working just like the win.ini, what cause the group not to be added. Then, I wrote myself a batch-script, which executes the net command for adding the domain-group, checks the command&#8217;s error code and if successful removes the scheduled task. The task itself I created using <em>/sc minute /mo 1</em>. By that, the task will be run every minute after the task-scheduler gets started on Windows&#8217; boot and try to add the group. The whole <strong>schtasks</strong> <em>/create</em> thing works and even my script runs when I doubleclick it, but somehow the scheduler can&#8217;t run the script I passed to him while the mini-setup was running. I tried to same <em>/create</em> command within Windows XP and it worked out &#8211; my batch file got executed after one minute, added the group, saw that there was no error adding the group and removed the schtasks job.</p>
<p>Now I&#8217;m trying to understand, why the job does not work when I create it within the mini-setup. It&#8217;s really annoying, because Windows really does not provide any information below the basic output. There is no way (or at least none I would know of) to see what the <strong>schtasks</strong> daemon actually does when trying to run the script and fails. There is no <strong>strace</strong>. Nothing. Argh.</p>
<p>It really rankles me that the last piece doesn&#8217;t work the way it actually should, because the other implementations run pretty smooth <strong>and lasting</strong>. *beckon to Thomas*</p>
<p>Hmpf&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2008/11/29/windows-xp-and-sysprepexe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

