<?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>Andrew Healey's Blog &#187; pst</title>
	<atom:link href="http://halfloaded.com/blog/tag/pst/feed/" rel="self" type="application/rss+xml" />
	<link>http://halfloaded.com</link>
	<description>Smash forehead on keyboard to continue...</description>
	<lastBuildDate>Tue, 20 Jul 2010 18:11:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Logon Script: Move Local PST Files To Network Share</title>
		<link>http://halfloaded.com/blog/logon-script-move-local-pst-files-to-network-share/</link>
		<comments>http://halfloaded.com/blog/logon-script-move-local-pst-files-to-network-share/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 03:25:05 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[logon script]]></category>
		<category><![CDATA[outlook]]></category>
		<category><![CDATA[pst]]></category>
		<category><![CDATA[vbScript]]></category>

		<guid isPermaLink="false">http://halfloaded.com/?p=322</guid>
		<description><![CDATA[Download Script: move-pst-to-network.zip So, my buddy (and former co-worker) called me yesterday for some help with a script he put together.  His script checked the local profile in Outlook for any PST files that were stored locally.  If it found any, it would them move them to the users home space.  We tried and tried [...]]]></description>
			<content:encoded><![CDATA[<p>Download Script: <a href="http://halfloaded.com/wp-content/uploads/2009/10/move-pst-to-network.zip">move-pst-to-network.zip</a></p>
<p>So, my buddy (and former co-worker) called me yesterday for some help with a script he put together.  His script checked the local profile in Outlook for any PST files that were stored locally.  If it found any, it would them move them to the users home space.  We tried and tried to get the script to work properly but it never seemed to work 100%.  Being that he is a good friend and this would be useful at work, I decided to take the work he had put in and get the thing working.<span id="more-322"></span></p>
<p>Here is what the script does:</p>
<ol>
<li>Checks to see if the computer is a laptop.  If it is, the user probably uses Outlook offline and/or over VPN so moving the PST to a network share will be detrimental to the user&#8217;s experience.  If you don&#8217;t care, just comment out lines 17-21.</li>
<li>Checks to see if Outlook is installed and can be launched properly.  If it can not, no sense in continuing the script.  It will exit.</li>
<li>Checks to see that the target (network) directory exists and is writable.  If it does not exist or is not writable, the script will exit.</li>
<li>Enumerates all the local stores and returns all the PST files.</li>
<li>Check to see if the PST files are stored on local drives.  It will exclude drives that are mapped network drives and/or removable media.</li>
<li>Check if a file already exists in the target directory with the same name.  If one does, it will not copy the file over. (I may update the script to move and rename the file to ensure all local PSTs are moved.</li>
<li>Removes all Personal Folders from Outlook that matched criteria.</li>
<li>Moves actual PST files to network share (Outlook will close to release the file lock on the PST file).</li>
<li>Adds all the Personal Folders back to Outlook.</li>
</ol>
<p>I have tested this on Windows XP w/ Office 2007 and Office 2003.  I am interested in hearing if this works or not in your environment.  I hope you find this useful.</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">'==========================================================================</span>
<span style="color: #008080; font-style: italic;">' VBScript Source File</span>
<span style="color: #008080; font-style: italic;">' NAME: move-pst-to-network</span>
<span style="color: #008080; font-style: italic;">' AUTHOR: Andrew J Healey &amp;amp; Nate Stevenson</span>
<span style="color: #008080; font-style: italic;">' WEB: http://halfloaded.com/</span>
<span style="color: #008080; font-style: italic;">' DATE  : 2010.14.2009</span>
<span style="color: #008080; font-style: italic;">' COMMENT: This script will move any mapped PST files that are located on</span>
<span style="color: #008080; font-style: italic;">'	local disks to a network share.</span>
<span style="color: #008080; font-style: italic;">' PROCESS: 1) determine if laptop; 2) determine if outlook installed</span>
<span style="color: #008080; font-style: italic;">'	3) determine local drives; 4) check for local pst's; 5) move pst's</span>
<span style="color: #008080; font-style: italic;">'	to network; 6) remap pst files</span>
<span style="color: #008080; font-style: italic;">'==========================================================================</span>
&nbsp;
<span style="color: #FF8000;">Option</span> Explicit
&nbsp;
<span style="color: #008080; font-style: italic;">'Determine if a laptop (remove if you don't care)</span>
<span style="color: #0600FF;">If</span> IsLaptop<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span> <span style="color: #FF8000;">Then</span>
	wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;Computer is a laptop or the chassis could not be determined.&quot;</span>
	wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;Exiting.&quot;</span>
	wscript.<span style="color: #0000FF;">quit</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Determine if outlook is installed</span>
<span style="color: #0600FF;">If</span> IsOutlookInstalled<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span> <span style="color: #FF8000;">Then</span>
	wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;Could not launch Outlook.&quot;</span>
	wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;Exiting.&quot;</span>
	wscript.<span style="color: #0000FF;">quit</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Get user name</span>
<span style="color: #0600FF;">Dim</span> WshNetwork : <span style="color: #FF8000;">Set</span> WshNetwork <span style="color: #008000;">=</span> WScript.<span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;WScript.Network&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">Dim</span> user : user <span style="color: #008000;">=</span> <span style="color: #0600FF;">lcase</span><span style="color: #000000;">&#40;</span>WshNetwork.<span style="color: #0000FF;">UserName</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> WshNetwork <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
&nbsp;
<span style="color: #0600FF;">Dim</span> strNetworkPath
<span style="color: #008080; font-style: italic;">'=========================================================================</span>
<span style="color: #008080; font-style: italic;">' Configuration Section</span>
strNetworkPath <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;\\servername\homes\&quot;</span> <span style="color: #008000;">&amp;</span>amp; user <span style="color: #008000;">&amp;</span>amp; <span style="color: #808080;">&quot;\&quot;</span>
<span style="color: #008080; font-style: italic;">' End Configuration Section</span>
<span style="color: #008080; font-style: italic;">'=========================================================================</span>
<span style="color: #008080; font-style: italic;">'Fix network path if forgot to include trailing slash...</span>
<span style="color: #0600FF;">If</span> <span style="color: #804040;">Not</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span>strNetworkPath,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;\&quot;</span> <span style="color: #FF8000;">Then</span> strNetworkPath <span style="color: #008000;">=</span> strNetworkPath <span style="color: #008000;">&amp;</span>amp; <span style="color: #808080;">&quot;\&quot;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Determine if network path is writable</span>
<span style="color: #0600FF;">If</span> IsPathWritable<span style="color: #000000;">&#40;</span>strNetworkPath<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span> <span style="color: #FF8000;">Then</span>
	wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;Remote path is not writable.&quot;</span>
	wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;Exiting.&quot;</span>
	wscript.<span style="color: #0000FF;">quit</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Instatiate objects</span>
<span style="color: #0600FF;">Dim</span> objOutlook, objNS, objFSO, objFolder
<span style="color: #FF8000;">Set</span> objOutlook <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Outlook.Application&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objNS <span style="color: #008000;">=</span> objOutlook.<span style="color: #0000FF;">GetNamespace</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;MAPI&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objFSO <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.FileSystemObject&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Sort through all stores in outlook and add all local pst</span>
<span style="color: #008080; font-style: italic;">' paths into an array. Then remove the store from outlook.</span>
<span style="color: #0600FF;">Dim</span> pstFiles
<span style="color: #0600FF;">Dim</span> count : count <span style="color: #008000;">=</span> <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span>
<span style="color: #0600FF;">Dim</span> arrPaths<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objFolder In objNS.<span style="color: #008000;">Folders</span>
	<span style="color: #0600FF;">If</span> GetPSTPath<span style="color: #000000;">&#40;</span>objFolder.<span style="color: #0000FF;">StoreID</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span>lt;<span style="color: #008000;">&amp;</span>gt; <span style="color: #808080;">&quot;&quot;</span> <span style="color: #FF8000;">Then</span>
		pstFiles <span style="color: #008000;">=</span> GetPSTPath<span style="color: #000000;">&#40;</span>objFolder.<span style="color: #0000FF;">StoreID</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0600FF;">If</span> IsStoredLocal<span style="color: #000000;">&#40;</span>pstFiles<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span> <span style="color: #FF8000;">Then</span>
			<span style="color: #0600FF;">If</span> objFSO.<span style="color: #0000FF;">FileExists</span><span style="color: #000000;">&#40;</span>strNetworkPath <span style="color: #008000;">&amp;</span>amp; <span style="color: #FF8000;">Mid</span><span style="color: #000000;">&#40;</span>pstFiles,<span style="color: #0600FF;">InStrRev</span><span style="color: #000000;">&#40;</span>pstFiles,<span style="color: #808080;">&quot;\&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span> <span style="color: #FF8000;">Then</span>
				wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;A pst file already exists with the same name.&quot;</span> <span style="color: #008000;">&amp;</span>amp; vbCrLf <span style="color: #008000;">&amp;</span>amp; _
						vbTab <span style="color: #008000;">&amp;</span>amp; <span style="color: #808080;">&quot;Source: &quot;</span> <span style="color: #008000;">&amp;</span>amp; pstPath <span style="color: #008000;">&amp;</span>amp; vbCrLf <span style="color: #008000;">&amp;</span>amp; _
						vbTab <span style="color: #008000;">&amp;</span>amp; <span style="color: #808080;">&quot;Target: &quot;</span> <span style="color: #008000;">&amp;</span>amp; strNetworkPath <span style="color: #008000;">&amp;</span>amp; <span style="color: #FF8000;">Mid</span><span style="color: #000000;">&#40;</span>pstPath,<span style="color: #0600FF;">InStrRev</span><span style="color: #000000;">&#40;</span>pstPath,<span style="color: #808080;">&quot;\&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
			<span style="color: #FF8000;">Else</span>
				count <span style="color: #008000;">=</span> count <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span>
				<span style="color: #0600FF;">ReDim</span> Preserve arrPaths<span style="color: #000000;">&#40;</span>count<span style="color: #000000;">&#41;</span>
				arrPaths<span style="color: #000000;">&#40;</span>count<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> pstFiles
				objOutlook.<span style="color: #0000FF;">Session</span>.<span style="color: #0000FF;">RemoveStore</span> objFolder
			<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
		<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
	<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">Next</span>
&nbsp;
objOutlook.<span style="color: #0000FF;">Session</span>.<span style="color: #0000FF;">Logoff</span>
objOutlook.<span style="color: #0000FF;">Quit</span>
<span style="color: #FF8000;">Set</span> objOutlook <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
<span style="color: #FF8000;">Set</span> objNS <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
&nbsp;
<span style="color: #0600FF;">if</span> count <span style="color: #008000;">&amp;</span>lt; <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">then</span>
	wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;No local PST Files Found.&quot;</span>
	wscript.<span style="color: #0000FF;">quit</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'If local PST files were found, move them to the new location</span>
<span style="color: #008080; font-style: italic;">' Echo output if the file already exists</span>
<span style="color: #0600FF;">Dim</span> pstPath
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> pstPath in arrPaths
	<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> <span style="color: #FF8000;">Resume</span> <span style="color: #FF8000;">Next</span>
		objFSO.<span style="color: #0000FF;">MoveFile</span> pstPath, strNetworkPath
		<span style="color: #0600FF;">If</span> <span style="color: #008000;">Err</span>.<span style="color: #0000FF;">Number</span> <span style="color: #008000;">&amp;</span>lt;<span style="color: #008000;">&amp;</span>gt; <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
			wscript.<span style="color: #0000FF;">sleep</span> <span style="color: #FF0000;">5000</span>
			objFSO.<span style="color: #0000FF;">MoveFile</span> pstPath, strNetworkPath
		<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
	<span style="color: #008000;">Err</span>.<span style="color: #0000FF;">Clear</span>
	<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> GoTo <span style="color: #FF0000;">0</span>
<span style="color: #FF8000;">Next</span>
<span style="color: #FF8000;">Set</span> objFSO <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Re-open outlook</span>
<span style="color: #FF8000;">Set</span> objOutlook <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Outlook.Application&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> objNS <span style="color: #008000;">=</span> objOutlook.<span style="color: #0000FF;">GetNamespace</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;MAPI&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Re-map Outlook folders</span>
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> pstPath in arrPaths
	objNS.<span style="color: #0000FF;">AddStore</span> strNetworkPath <span style="color: #008000;">&amp;</span>amp; <span style="color: #FF8000;">Mid</span><span style="color: #000000;">&#40;</span>pstPath,<span style="color: #0600FF;">InStrRev</span><span style="color: #000000;">&#40;</span>pstPath,<span style="color: #808080;">&quot;\&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Next</span>
&nbsp;
objOutlook.<span style="color: #0000FF;">Session</span>.<span style="color: #0000FF;">Logoff</span>
objOutlook.<span style="color: #0000FF;">Quit</span>
<span style="color: #FF8000;">Set</span> objOutlook <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
<span style="color: #FF8000;">Set</span> objNS <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
wscript.<span style="color: #0000FF;">echo</span> <span style="color: #808080;">&quot;Done.&quot;</span>
wscript.<span style="color: #0000FF;">quit</span>
&nbsp;
<span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Function</span> GetPSTPath<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">byVal</span> <span style="color: #FF8000;">input</span><span style="color: #000000;">&#41;</span>
	<span style="color: #008080; font-style: italic;">'Will return the path of all PST files</span>
	<span style="color: #008080; font-style: italic;">' Took Function from: http://www.vistax64.com/vb-script/</span>
	<span style="color: #0600FF;">Dim</span> i, strSubString, strPath
	<span style="color: #FF8000;">For</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span> <span style="color: #FF8000;">To</span> <span style="color: #FF8000;">Len</span><span style="color: #000000;">&#40;</span><span style="color: #FF8000;">input</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Step</span> <span style="color: #FF0000;">2</span>
		strSubString <span style="color: #008000;">=</span> <span style="color: #FF8000;">Mid</span><span style="color: #000000;">&#40;</span><span style="color: #FF8000;">input</span>,i,<span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0600FF;">If</span> <span style="color: #804040;">Not</span> strSubString <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;00&quot;</span> <span style="color: #FF8000;">Then</span>
			strPath <span style="color: #008000;">=</span> strPath <span style="color: #008000;">&amp;</span>amp; <span style="color: #0600FF;">ChrW</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;&amp;amp;H&quot;</span> <span style="color: #008000;">&amp;</span>amp; strSubString<span style="color: #000000;">&#41;</span>
		<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
	<span style="color: #FF8000;">Next</span>
&nbsp;
	<span style="color: #0600FF;">Select</span> <span style="color: #0600FF;">Case</span> <span style="color: #0600FF;">True</span>
		<span style="color: #0600FF;">Case</span> <span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span>strPath,<span style="color: #808080;">&quot;:\&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span>gt; <span style="color: #FF0000;">0</span>
			GetPSTPath <span style="color: #008000;">=</span> <span style="color: #FF8000;">Mid</span><span style="color: #000000;">&#40;</span>strPath,<span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span>strPath,<span style="color: #808080;">&quot;:\&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0600FF;">Case</span> <span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span>strPath,<span style="color: #808080;">&quot;\\&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span>gt; <span style="color: #FF0000;">0</span>
			GetPSTPath <span style="color: #008000;">=</span> <span style="color: #FF8000;">Mid</span><span style="color: #000000;">&#40;</span>strPath,<span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span>strPath,<span style="color: #808080;">&quot;\\&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Select</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Function</span> IsLaptop<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #008080; font-style: italic;">'Determine if the computer is a mobile machine</span>
	<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> <span style="color: #FF8000;">Resume</span> <span style="color: #FF8000;">Next</span>
		<span style="color: #008080; font-style: italic;">'Instantiate objects</span>
		<span style="color: #0600FF;">Dim</span> objWMIService, colChassis, objChassis, strChassisType
		<span style="color: #FF8000;">Set</span> objWMIService <span style="color: #008000;">=</span> GetObject<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #FF8000;">Set</span> colChassis <span style="color: #008000;">=</span> objWMIService.<span style="color: #0000FF;">ExecQuery</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Select * from Win32_SystemEnclosure&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
		<span style="color: #008080; font-style: italic;">'Check chassis type</span>
		<span style="color: #008080; font-style: italic;">'http://msdn.microsoft.com/en-us/library/aa394474%28VS.85%29.aspx</span>
		<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objChassis in colChassis
			<span style="color: #FF8000;">For</span>  <span style="color: #0600FF;">Each</span> strChassisType in objChassis.<span style="color: #0000FF;">ChassisTypes</span>
				<span style="color: #0600FF;">If</span> <span style="color: #000000;">&#40;</span>strChassisType <span style="color: #008000;">&amp;</span>gt;<span style="color: #008000;">=</span> <span style="color: #FF0000;">8</span> <span style="color: #804040;">And</span> strChassisType <span style="color: #008000;">&amp;</span>lt;<span style="color: #008000;">=</span><span style="color: #FF0000;">12</span><span style="color: #000000;">&#41;</span> Or <span style="color: #000000;">&#40;</span>strChassisType <span style="color: #008000;">=</span> <span style="color: #FF0000;">14</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
					IsLaptop <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
					<span style="color: #0600FF;">Exit</span> <span style="color: #FF8000;">For</span>
				<span style="color: #FF8000;">Else</span>
					IsLaptop <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
				<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
			<span style="color: #FF8000;">Next</span>
		<span style="color: #FF8000;">Next</span>
	<span style="color: #0600FF;">If</span> <span style="color: #008000;">Err</span>.<span style="color: #0000FF;">Number</span> <span style="color: #008000;">&amp;</span>lt;<span style="color: #008000;">&amp;</span>gt; <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span> IsLaptop <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
	<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> GoTo <span style="color: #FF0000;">0</span>
	<span style="color: #FF8000;">Set</span> colChassis <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
	<span style="color: #FF8000;">Set</span> objWMIService <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
	objChassis <span style="color: #008000;">=</span> <span style="color: #FF8000;">Null</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span> 
&nbsp;
<span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Function</span> IsOutlookInstalled<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #008080; font-style: italic;">'Function will return false if unable to launch outlook</span>
	<span style="color: #008080; font-style: italic;">' This adds some overhead but it is ultimately the best</span>
	<span style="color: #008080; font-style: italic;">' way to truly determine if script will function properly.</span>
	<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> <span style="color: #FF8000;">Resume</span> <span style="color: #FF8000;">Next</span>
		<span style="color: #FF8000;">Set</span> objOutlook <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Outlook.Application&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0600FF;">If</span> <span style="color: #008000;">Err</span>.<span style="color: #0000FF;">Number</span> <span style="color: #008000;">&amp;</span>lt;<span style="color: #008000;">&amp;</span>gt; <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
			IsOutlookInstalled <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
			<span style="color: #0600FF;">Exit</span> <span style="color: #0600FF;">Function</span>
		<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
	<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> GoTo <span style="color: #FF0000;">0</span>
	IsOutlookInstalled <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
	objOutlook.<span style="color: #0000FF;">Session</span>.<span style="color: #0000FF;">Logoff</span>
	objOutlook.<span style="color: #0000FF;">Quit</span>
	<span style="color: #FF8000;">Set</span> objOutlook <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Function</span> IsPathWritable<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">byVal</span> strPath<span style="color: #000000;">&#41;</span>
	<span style="color: #008080; font-style: italic;">'Check to make sure the path is writable. If it is not, no</span>
	<span style="color: #008080; font-style: italic;">' need to continue processing.</span>
	<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> <span style="color: #FF8000;">Resume</span> <span style="color: #FF8000;">Next</span>
		<span style="color: #FF8000;">Set</span> objFSO <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.FileSystemObject&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0600FF;">Dim</span> min : min <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>
		<span style="color: #0600FF;">Dim</span> max : max <span style="color: #008000;">=</span> <span style="color: #FF0000;">1000</span>
		<span style="color: #0600FF;">Dim</span> rand : rand <span style="color: #008000;">=</span> <span style="color: #0600FF;">Int</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>max <span style="color: #008000;">-</span> min <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">*</span> <span style="color: #0600FF;">Rnd</span> <span style="color: #008000;">+</span> min<span style="color: #000000;">&#41;</span>
		<span style="color: #0600FF;">Dim</span> fullFileName : fullFileName <span style="color: #008000;">=</span> strPath <span style="color: #008000;">&amp;</span>amp; <span style="color: #808080;">&quot;temporary-&quot;</span> <span style="color: #008000;">&amp;</span>amp; rand <span style="color: #008000;">&amp;</span>amp; <span style="color: #808080;">&quot;.txt&quot;</span>
		<span style="color: #0600FF;">Dim</span> objFile : <span style="color: #FF8000;">Set</span> objFile <span style="color: #008000;">=</span> objFSO.<span style="color: #0000FF;">CreateTextFile</span><span style="color: #000000;">&#40;</span>fullFileName, <span style="color: #0600FF;">True</span><span style="color: #000000;">&#41;</span>
		objFile.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Test file creation of &quot;</span> <span style="color: #008000;">&amp;</span>amp; fullFileName<span style="color: #000000;">&#41;</span>
		objFile.<span style="color: #0600FF;">Close</span>
		<span style="color: #0600FF;">If</span> objFSO.<span style="color: #0000FF;">FileExists</span><span style="color: #000000;">&#40;</span>fullFileName<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
			IsPathWritable <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
			objFSO.<span style="color: #0000FF;">DeleteFile</span><span style="color: #000000;">&#40;</span>fullFileName<span style="color: #000000;">&#41;</span>
		<span style="color: #FF8000;">Else</span>
			IsPathWritable <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
		<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
	<span style="color: #0600FF;">If</span> <span style="color: #008000;">Err</span>.<span style="color: #0000FF;">Number</span> <span style="color: #008000;">&amp;</span>lt;<span style="color: #008000;">&amp;</span>gt; <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span> IsPathWritable <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
	<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> GoTo <span style="color: #FF0000;">0</span>
	<span style="color: #FF8000;">Set</span> objFile <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
	<span style="color: #FF8000;">Set</span> objFSO <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
	rand <span style="color: #008000;">=</span> <span style="color: #FF8000;">Null</span>
	max <span style="color: #008000;">=</span> <span style="color: #FF8000;">Null</span>
	min <span style="color: #008000;">=</span> <span style="color: #FF8000;">Null</span>
	fullFileName <span style="color: #008000;">=</span> <span style="color: #FF8000;">Null</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Function</span> IsStoredLocal<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> fullFileName<span style="color: #000000;">&#41;</span>
	<span style="color: #008080; font-style: italic;">'Check if the PST is stored locally or on a mapped or removable drive</span>
	<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> <span style="color: #FF8000;">Resume</span> <span style="color: #FF8000;">Next</span>
		<span style="color: #0600FF;">Dim</span> objDisk, objWMIService, colDisks
		<span style="color: #FF8000;">Set</span> objWMIService <span style="color: #008000;">=</span> GetObject<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #FF8000;">Set</span> colDisks <span style="color: #008000;">=</span> objWMIService.<span style="color: #0000FF;">ExecQuery</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SELECT * FROM Win32_LogicalDisk&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> objDisk in colDisks
			<span style="color: #0600FF;">If</span> objDisk.<span style="color: #0000FF;">DriveType</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">3</span> <span style="color: #FF8000;">Then</span>
				<span style="color: #0600FF;">If</span> <span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span>fullFileName,objDisk.<span style="color: #0000FF;">DeviceID</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span>gt; <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
					IsStoredLocal <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
					<span style="color: #0600FF;">Exit</span> <span style="color: #FF8000;">For</span>
				<span style="color: #FF8000;">Else</span>
					IsStoredLocal <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
				<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
			<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
		<span style="color: #FF8000;">Next</span>
	<span style="color: #0600FF;">If</span> <span style="color: #008000;">Err</span>.<span style="color: #0000FF;">Number</span> <span style="color: #008000;">&amp;</span>lt;<span style="color: #008000;">&amp;</span>gt; <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span> IsLocalDrive <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
	<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> GoTo <span style="color: #FF0000;">0</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></pre></div></div>



<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://halfloaded.com/blog/logon-script-move-local-pst-files-to-network-share/&amp;t=Logon+Script%3A+Move+Local+PST+Files+To+Network+Share" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://halfloaded.com/blog/logon-script-move-local-pst-files-to-network-share/&amp;title=Logon+Script%3A+Move+Local+PST+Files+To+Network+Share&amp;summary=Download%20Script%3A%20move-pst-to-network.zip%0D%0A%0D%0ASo%2C%20my%20buddy%20%28and%20former%20co-worker%29%20called%20me%20yesterday%20for%20some%20help%20with%20a%20script%20he%20put%20together.%C2%A0%20His%20script%20checked%20the%20local%20profile%20in%20Outlook%20for%20any%20PST%20files%20that%20were%20stored%20locally.%C2%A0%20If%20it%20found%20any%2C%20it%20would%20them%20move%20them%20to%20the%20users%20home%20&amp;source=Andrew Healey's Blog" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Logon+Script%3A+Move+Local+PST+Files+To+Network+Share+-+http://b2l.me/b4gey&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=Logon+Script%3A+Move+Local+PST+Files+To+Network+Share&amp;du=http://halfloaded.com/blog/logon-script-move-local-pst-files-to-network-share/&amp;cn=Download%20Script%3A%20move-pst-to-network.zip%0D%0A%0D%0ASo%2C%20my%20buddy%20%28and%20former%20co-worker%29%20called%20me%20yesterday%20for%20some%20help%20with%20a%20script%20he%20put%20together.%C2%A0%20His%20script%20checked%20the%20local%20profile%20in%20Outlook%20for%20any%20PST%20files%20that%20were%20stored%20locally.%C2%A0%20If%20it%20found%20any%2C%20it%20would%20them%20move%20them%20to%20the%20users%20home%20" rel="nofollow" class="external" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://halfloaded.com/blog/logon-script-move-local-pst-files-to-network-share/&amp;title=Logon+Script%3A+Move+Local+PST+Files+To+Network+Share" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://halfloaded.com/blog/logon-script-move-local-pst-files-to-network-share/&amp;submitHeadline=Logon+Script%3A+Move+Local+PST+Files+To+Network+Share&amp;submitSummary=Download%20Script%3A%20move-pst-to-network.zip%0D%0A%0D%0ASo%2C%20my%20buddy%20%28and%20former%20co-worker%29%20called%20me%20yesterday%20for%20some%20help%20with%20a%20script%20he%20put%20together.%C2%A0%20His%20script%20checked%20the%20local%20profile%20in%20Outlook%20for%20any%20PST%20files%20that%20were%20stored%20locally.%C2%A0%20If%20it%20found%20any%2C%20it%20would%20them%20move%20them%20to%20the%20users%20home%20&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://halfloaded.com/blog/logon-script-move-local-pst-files-to-network-share/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://halfloaded.com/blog/logon-script-move-local-pst-files-to-network-share/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22Logon%20Script%3A%20Move%20Local%20PST%20Files%20To%20Network%20Share%22&amp;body=Link: http://halfloaded.com/blog/logon-script-move-local-pst-files-to-network-share/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Download%20Script%3A%20move-pst-to-network.zip%0D%0A%0D%0ASo%2C%20my%20buddy%20%28and%20former%20co-worker%29%20called%20me%20yesterday%20for%20some%20help%20with%20a%20script%20he%20put%20together.%C2%A0%20His%20script%20checked%20the%20local%20profile%20in%20Outlook%20for%20any%20PST%20files%20that%20were%20stored%20locally.%C2%A0%20If%20it%20found%20any%2C%20it%20would%20them%20move%20them%20to%20the%20users%20home%20" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://halfloaded.com/blog/logon-script-move-local-pst-files-to-network-share/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
