<?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>Others &#8211; Quan Tran</title>
	<atom:link href="https://qtran.info/category/scripting-tips/batch-powershell-c-c/feed/" rel="self" type="application/rss+xml" />
	<link>https://qtran.info</link>
	<description></description>
	<lastBuildDate>Sat, 20 Oct 2018 14:12:34 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>

<image>
	<url>https://qtran.info/wp-content/uploads/2018/10/cropped-logo-2-32x32.jpg</url>
	<title>Others &#8211; Quan Tran</title>
	<link>https://qtran.info</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Powershell WOL script</title>
		<link>https://qtran.info/powershell-wol-script/</link>
		
		<dc:creator><![CDATA[quan3t]]></dc:creator>
		<pubDate>Sat, 20 Oct 2018 14:12:34 +0000</pubDate>
				<category><![CDATA[Others]]></category>
		<guid isPermaLink="false"></guid>

					<description><![CDATA[Script to wake a computer via network using Windows Powershell. # Script to wake up a computer over network. param( [string]$mac = &#8217;00:00:00:00:00:00&#8242; #address of the network card (MAC address) ) #checks the syntax of MAC address if (!($mac -like &#8220;*:*:*:*:*:*&#8221;) -or ($mac -like &#8220;*-*-*-*-*-*&#8221;)){ write-error &#8220;mac address not in correct format&#8221; break } #build magic package http://en.wikipedia.org/wiki/Wake-on-LAN#Magic_packet $string=@($mac.split(&#8220;:&#8221;&#8221;-&#8220;) &#124; foreach {$_.insert(0,&#8221;0x&#8221;)}) $target = [byte[]]($string[0], $string[1], $string[2], $string[3], $string[4], $string[5]) # The magic packet is a broadcast frame containing anywhere [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Script to wake a computer via network using Windows Powershell.</p>
<blockquote><p># Script to wake up a computer over network.</p>
<p>param(<br />
[string]$mac = &#8217;00:00:00:00:00:00&#8242; #address of the network card (MAC address)<br />
)</p>
<p>#checks the syntax of MAC address<br />
if (!($mac -like &#8220;*:*:*:*:*:*&#8221;) -or ($mac -like &#8220;*-*-*-*-*-*&#8221;)){<br />
write-error &#8220;mac address not in correct format&#8221;<br />
break<br />
}</p>
<p>#build magic package http://en.wikipedia.org/wiki/Wake-on-LAN#Magic_packet<br />
$string=@($mac.split(&#8220;:&#8221;&#8221;-&#8220;) | foreach {$_.insert(0,&#8221;0x&#8221;)})<br />
$target = [byte[]]($string[0], $string[1], $string[2], $string[3], $string[4], $string[5])<br />
# The magic packet is a broadcast frame containing anywhere within its payload 6 bytes of all 255 (FF FF FF FF FF FF in hexadecimal)<br />
$packet = [byte[]](,0xFF * 102)<br />
# followed by sixteen repetitions of the target computer&#8217;s 48-bit MAC address, for a total of 102 bytes.<br />
6..101 |% { $packet[$_] = $target[($_%6)]}</p>
<p># .NET framework lib para sockets<br />
$UDPclient = new-Object System.Net.Sockets.UdpClient<br />
$UDPclient.Connect(([System.Net.IPAddress]::Broadcast),4000)<br />
$UDPclient.Send($packet, $packet.Length) | out-null</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Batch FOR loop and variable modifiers</title>
		<link>https://qtran.info/batch-for-loop-and-variable-modifiers/</link>
		
		<dc:creator><![CDATA[quan3t]]></dc:creator>
		<pubDate>Fri, 19 Oct 2018 20:18:11 +0000</pubDate>
				<category><![CDATA[Others]]></category>
		<guid isPermaLink="false"></guid>

					<description><![CDATA[Write a FOR loop such as below @echo off for /R &#8220;C:\Users\Admin\Desktop&#8221; %%I in (*.*) do ( echo %%~nI ) pause To modifier the variable I, use the following %~I Expands %I which removes any surrounding quotation marks (&#8220;&#8221;). %~fI Expands %I to a fully qualified path name. %~dI Expands %I to a drive letter only. %~pI Expands %I to a path only. %~nI Expands %I to a file name only. %~xI Expands %I to a file extension only. %~sI [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Write a FOR loop such as below</p>
<blockquote><p>@echo off<br />
for /R &#8220;C:\Users\Admin\Desktop&#8221; %%I in (*.*) do (<br />
echo %%~nI<br />
)<br />
pause</p></blockquote>
<p>To modifier the variable I, use the following</p>
<blockquote><p>%~I Expands %I which removes any surrounding quotation marks (&#8220;&#8221;).<br />
%~fI Expands %I to a fully qualified path name.<br />
%~dI Expands %I to a drive letter only.<br />
%~pI Expands %I to a path only.<br />
%~nI Expands %I to a file name only.<br />
%~xI Expands %I to a file extension only.<br />
%~sI Expands path to contain short names only.<br />
%~aI Expands %I to the file attributes of file.<br />
%~tI Expands %I to the date and time of file.<br />
%~zI Expands %I to the size of file.</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
