vbs to copy nk2<p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">this is driving me crazy.</span><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Fist a batch file would do this so simple in 4 lines but my company wants only vbs.</span><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Here is what I need.</span><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">When the user logs on a vbs will run that copies there nk2 file to s sever share.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">If they don't have one it skips it.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">We use Vista and XP so %appdata%\Microsoft\outlook\*.nk2.</span><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">VBS does not understand %appdata% or at least I don't know how to make it understand.</span><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">does anyone have this or something like it?</span><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Thanks</span></p>© 2009 Microsoft Corporation. All rights reserved.Sun, 05 Jul 2009 13:24:52 Ze1f63ac2-109d-4ace-8c11-dd4392b49dcbhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#e1f63ac2-109d-4ace-8c11-dd4392b49dcbhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#e1f63ac2-109d-4ace-8c11-dd4392b49dcbtnetplushttp://social.technet.microsoft.com/Profile/en-US/?user=tnetplusvbs to copy nk2<p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">this is driving me crazy.</span><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Fist a batch file would do this so simple in 4 lines but my company wants only vbs.</span><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Here is what I need.</span><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">When the user logs on a vbs will run that copies there nk2 file to s sever share.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">If they don't have one it skips it.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">We use Vista and XP so %appdata%\Microsoft\outlook\*.nk2.</span><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">VBS does not understand %appdata% or at least I don't know how to make it understand.</span><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">does anyone have this or something like it?</span><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Thanks</span></p>Sat, 04 Jul 2009 11:43:14 Z2009-07-04T11:43:14Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#238e8ae1-a16a-43b2-bbe1-ed4ea994a834http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#238e8ae1-a16a-43b2-bbe1-ed4ea994a834perhofhttp://social.technet.microsoft.com/Profile/en-US/?user=perhofvbs to copy nk2To use an environment variable in VBScript you will need to expand it first.<br/>This is done using the ExpandEnvirnomentStrings method of the Wscript.Shell object.<br/>Like this:<br/><br/>Set objWSHShell = CreateObject(&quot;Wscript.Shell&quot;)<br/>strPath =objWSHShell.ExpandEnvironmentStrings(&quot;<span style="font-family:Calibri;font-size:x-small">%appdata%\Microsoft\outlook\*.nk2</span>&quot;)<br/>Sat, 04 Jul 2009 12:22:41 Z2009-07-04T12:22:41Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#01e84221-b183-4065-a838-ab093a24220ehttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#01e84221-b183-4065-a838-ab093a24220etnetplushttp://social.technet.microsoft.com/Profile/en-US/?user=tnetplusvbs to copy nk2Thanks so much.  I have made some progress.<br/><br/>As a update I found this script and I have altered it slightly for the vista variables as well as xp.  I have also added the echo commands as a temp thing so I can see if it is finding the file.  It is not finding it on either test pc (vista or xp).<br/><br/>The issue i think it is looking for a nk2 file names username.nk2 and ours most likely will not be named that.  They may be outlook.nk2 or default user.nk2 or anything.  a user may have a old nk2 or nk2 from another account.  So can this be modified to look for any nk2 in the paths stated  and copy it to the share. <br/>I know nothing of VBS so i THINK this is correct.<br/><br/><br/><br/>rem start<br/><br/><br/>Option Explicit<br/><br/>Dim objFSO, objShell<br/>Dim strUser<br/>Set objShell = CreateObject(&quot;Wscript.Shell&quot;)<br/>strUser = objShell.ExpandEnvironmentStrings(&quot;%USERNAME%&quot;)<br/> <br/>Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)<br/> <br/>If objFSO.FileExists(&quot;C:\Documents and Settings\&quot; &amp; strUser &amp; &quot;\Application Data\Microsoft\Outlook\&quot; &amp; strUser &amp; &quot;.NK2&quot;) Then<br/>     objFSO.CopyFile &quot;C:\Documents and Settings\&quot; &amp; strUser &amp; &quot;\Application Data\Microsoft\Outlook\&quot; &amp; strUser &amp; &quot;.NK2&quot; , &quot;\\server\&quot; &amp; strUser &amp; &quot;\&quot; &amp; strUser &amp; &quot;.NK2&quot; , True<br/>     WScript.Echo(&quot;XP File exists!&quot;) <br/>Else <br/>WScript.Echo(&quot;xp File does not exist!&quot;)<br/>End If<br/> <br/> If objFSO.FileExists(&quot;C:\Users\&quot; &amp; strUser &amp; &quot;\AppData\Roaming\Microsoft\Outlook\&quot; &amp; strUser &amp; &quot;.NK2&quot;) Then<br/>     objFSO.CopyFile &quot;C:\Users\&quot; &amp; strUser &amp; &quot;\AppData\Roaming\Microsoft\Outlook\&quot; &amp; strUser &amp; &quot;.NK2&quot; , &quot;\\server\&quot; &amp; strUser &amp; &quot;\&quot; &amp; strUser &amp; &quot;.NK2&quot; , True<br/>     WScript.Echo(&quot;Vista File exists!&quot;) <br/>Else <br/>WScript.Echo(&quot;Vista File does not exist!&quot;)<br/>End If<br/><br/>set objFSO = nothing<br/>set strUser = nothing<br/>WScript.Quit<br/>Sat, 04 Jul 2009 15:34:16 Z2009-07-04T15:34:16Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#4edf291c-fce7-48a3-8b94-d815fe87947chttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#4edf291c-fce7-48a3-8b94-d815fe87947cperhofhttp://social.technet.microsoft.com/Profile/en-US/?user=perhofvbs to copy nk2Your first approach was better. Use the %APPDATA% variable. It will work with both XP and Vista and simplifies things.<br/>You also had a *.nk2 in there which is the way to go.<br/>I think this should do it:<br/> <pre lang=x-vbnet>Set objWshShell = CreateObject(&quot;Wscript.Shell&quot;) strSource = objWshShell.ExpandEnvironmentStrings(&quot;%APPDATA%\Microsoft\outlook\*.nk2&quot;) strTarget = objShell.ExpandEnvironmentStrings(<a>\\server\%USERNAME%\</a>) Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;) On Error Resume Next objFSO.CopyFile strSource, strTarget, True If Err.Number = 0 Then Wscript.Echo &quot;File copied successfully&quot; Else Wscript.Echo &quot;Error &quot; &amp; Err.Number &amp; vbTab &amp; Err.Description End If</pre> <br/>You can skip everything after objFSO.CopyFile if you don't need errorhandling but keep the On Error Resume Next statement or the script will fail if there are no nk2 files.<br/>Sat, 04 Jul 2009 17:37:47 Z2009-07-04T17:37:47Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#e9415d73-2825-4d64-a93d-71b4712615a5http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#e9415d73-2825-4d64-a93d-71b4712615a5tnetplushttp://social.technet.microsoft.com/Profile/en-US/?user=tnetplusvbs to copy nk2<p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">First thank you so much I truly don't know how to thank you.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">However when I run it I receive the below error.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">syntax error line 4 char 47<span style="">  </span>the code is 800A03ea which is somewhere in this area</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="line-height:115%;font-family:'Courier New';color:black;font-size:10pt">strTarget = objShell.ExpandEnvironmentStrings<span style="text-decoration:underline"><span style="background:yellow">(&lt;a</span></span>&gt;\\server\%USERNAME%\&lt;/a&gt;)</span></p>Sat, 04 Jul 2009 20:22:13 Z2009-07-04T20:22:13Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#8048ed97-84cb-4b52-9005-78e538b0a9a5http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#8048ed97-84cb-4b52-9005-78e538b0a9a5tnetplushttp://social.technet.microsoft.com/Profile/en-US/?user=tnetplusvbs to copy nk2<p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">I have put my server path in the place where it says \\server but I can determine what the &lt;a&gt; at the start of the path and the &lt;/a&gt; at the end is for.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">I am still getting the same error.<span style="">  </span>I have tried removing the a's and few other variations but still the same error and I am unable to determine the reason for the error.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p>Sat, 04 Jul 2009 21:36:08 Z2009-07-04T21:36:08Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#7af775ec-f3ee-4b10-b601-8bce9dbcb54ahttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#7af775ec-f3ee-4b10-b601-8bce9dbcb54aperhofhttp://social.technet.microsoft.com/Profile/en-US/?user=perhofvbs to copy nk2I have no idea what happened to the code when I posted it but it was wrong. It should be quotes - not an &lt;a&gt; tag.<br/><br/>strTarget = objShell.ExpandEnvironmentStrings(&quot;<a>\\server\%USERNAME%\</a>&quot;)<br/>Sat, 04 Jul 2009 21:52:03 Z2009-07-04T21:52:03Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#c685e458-e7eb-4138-add0-f4070a7fe5c9http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#c685e458-e7eb-4138-add0-f4070a7fe5c9tnetplushttp://social.technet.microsoft.com/Profile/en-US/?user=tnetplusvbs to copy nk2<p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">it is still giving a error on the same line but different place.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri"><span style="font-size:small">Line 4 Char: 1<span style="">   </span>error object required: 'objshell'<br/>strTarget = objShell.ExpandEnvironmentStrings(&quot;</span><a><span style="font-size:small">\\SUN-RON-XP\nk2\%USERNAME%\</span></a><span style="font-size:small">&quot;)<br/><br/></span> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:small">The \\sun-ron-xp is a test pc on my network</span></p> </span></p>Sat, 04 Jul 2009 22:13:56 Z2009-07-04T22:13:56Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#d21adb4c-badd-4424-b35c-e10ea62626a9http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#d21adb4c-badd-4424-b35c-e10ea62626a9tnetplushttp://social.technet.microsoft.com/Profile/en-US/?user=tnetplusvbs to copy nk2<p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">I changed one thing on the third line see below.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Set objWshShell = CreateObject(&quot;Wscript.Shell&quot;)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">strSource = objWshShell.ExpandEnvironmentStrings(&quot;%APPDATA%\Microsoft\outlook\*.nk2&quot;)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">strTarget = <span style="background:yellow">objWshShel</span>l.ExpandEnvironmentStrings(&quot;\\SUN-RON-XP\nk2\%USERNAME%\&quot;)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">It did not give a VB error <span style=""> </span>but it gave               Error 76 path not found on both XP and vista</span></p>Sat, 04 Jul 2009 23:05:06 Z2009-07-04T23:05:06Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#ae854726-4ec6-4179-9e5a-ca56598dd32bhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#ae854726-4ec6-4179-9e5a-ca56598dd32btnetplushttp://social.technet.microsoft.com/Profile/en-US/?user=tnetplusvbs to copy nk2<p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Also when i put %APPDATA%\Microsoft\outlook\*.nk2 in the run bar it does not find anything. If i put %APPDATA%\Microsoft\outlook\ it does get me to the directory.<span style="">  </span>I wonder if that wildcard is throwing the VBS for a loop.<span style="">  </span>Still you are light years ahead of me on this and i do thank you for any time you will give me.</span></p>Sat, 04 Jul 2009 23:10:17 Z2009-07-04T23:10:17Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#89ebbad6-04ee-41e7-bd35-c4d29bf227f8http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#89ebbad6-04ee-41e7-bd35-c4d29bf227f8tnetplushttp://social.technet.microsoft.com/Profile/en-US/?user=tnetplusvbs to copy nk2<p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">I am so excited this is as close as I have came thanks to you.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Below does work if I change it to (see bottom script)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">The issue is it needs to create a folder for that user.  <span style="line-height:115%;font-family:'Calibri','sans-serif';font-size:11pt">I had to change it to where the path was just \\server\nk2 from \\server\nk2\%username% as it was not finding that directory because it did not exist</span></span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">So if it is john smith logs on and his log on is jsmith it should create the folder jsmith in \\server\nk2\.<span style="">  </span>Also will this overwrite previous nk2 files, as it will run at each log on and needs to overwrite each time.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Thanks again.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Set objWshShell = CreateObject(&quot;Wscript.Shell&quot;)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Set objShell = CreateObject(&quot;Wscript.Shell&quot;)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">strSource = objWshShell.ExpandEnvironmentStrings(&quot;%APPDATA%\Microsoft\outlook\*.nk2&quot;)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">strTarget = objShell.ExpandEnvironmentStrings(&quot;\\SUN-RON-XP\nk2\&quot;)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">On Error Resume Next</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">objFSO.CopyFile strSource, strTarget, True</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">If Err.Number = 0 Then</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:small"><span style="font-family:Calibri"><span style="">                </span>Wscript.Echo &quot;File copied successfully&quot;</span></span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Else</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:small"><span style="font-family:Calibri"><span style="">                </span>Wscript.Echo &quot;Error &quot; &amp; Err.Number &amp; vbTab &amp; Err.Description</span></span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">End If</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p>Sat, 04 Jul 2009 23:34:46 Z2009-07-04T23:34:46Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#339f6bb1-349c-441b-a50e-af012bbcf726http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#339f6bb1-349c-441b-a50e-af012bbcf726NickHunyadyhttp://social.technet.microsoft.com/Profile/en-US/?user=NickHunyadyvbs to copy nk2Couple of pointers,<br/><br/>Like perhof's script shows you only need one call to Wscript.Shell<br/><br/> <pre>Set objWshShell = CreateObject(&quot;Wscript.Shell&quot;) strSource = objWshShell.ExpandEnvironmentStrings(&quot;%APPDATA%\Microsoft\outlook\*.nk2&quot;) strTarget = objWshShell.ExpandEnvironmentStrings(&quot;\\SUN-RON-XP\nk2\&quot;) </pre> <p>To get the current user you can add this:</p> <pre>Set WshNetwork = WScript.CreateObject(&quot;WScript.Network&quot;) strUserName = WshNetwork.UserName</pre> <p>Then to create a folder it would be:<br/></p> <pre>objFSO.CreateFolder strTarget &amp; strUserName<br/></pre> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:small;font-family:Calibri"><span style="font-size:x-small"></span></span></p> <p><br/><br/> </p>Sun, 05 Jul 2009 06:43:19 Z2009-07-05T06:43:19Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#d9461fb9-23b4-4194-9a9a-127bb3d22826http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#d9461fb9-23b4-4194-9a9a-127bb3d22826perhofhttp://social.technet.microsoft.com/Profile/en-US/?user=perhofvbs to copy nk2Yes, I'm sorry about that Typo. Even did it twice... sigh. You only need one shell object.<br/>You can skip the strUsername part completely if you want to since we're already expanding environment strings.<br/>Just use <a>\\SUN-RON-XP\nk2\%USERNAME%\</a> for strTarget (why did you remove %username% from my example?) and then do this to create the folder when necessary:<br/><br/>If not objFSO.FolderExists(strTarget) Then objFSO.CreateFolder(strTarget)<br/><br/>You said that it doesn't work on both Vista and XP. Is that still so? Where does it NOT work?<br/>You should be able to put <span style="font-family:Calibri;font-size:x-small">%APPDATA%\Microsoft\outlook in the address bar in both operating systems and end up in the right folders.<br/>%APPDATA%\Microsoft\outlook\*.nk2 shouldn't work though. That's not a valid path in Explorer.</span>Sun, 05 Jul 2009 07:24:42 Z2009-07-05T07:24:42Zhttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#68556f87-3f6b-4cb1-8944-09df95439b6ehttp://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e1f63ac2-109d-4ace-8c11-dd4392b49dcb#68556f87-3f6b-4cb1-8944-09df95439b6etnetplushttp://social.technet.microsoft.com/Profile/en-US/?user=tnetplusvbs to copy nk2<p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Success.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Thanks so much for all your time.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">It works on vista, windows 7 and XP perfectly.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">I have pasted the final result below.<span style="">  </span>Although still a lover of batch files as it did this simply in 3 or 4 lines at least VBS is a LITTLE less unknown to me today.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Thanks again.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small"> </span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">REM start of finished script</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Set objWshShell = CreateObject(&quot;Wscript.Shell&quot;)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">strSource = objWshShell.ExpandEnvironmentStrings(&quot;%APPDATA%\Microsoft\outlook\*.nk2&quot;)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">strTarget = objWshShell.ExpandEnvironmentStrings(&quot;\\server\%USERNAME%\&quot;)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">If not objFSO.FolderExists(strTarget) Then objFSO.CreateFolder(strTarget)</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">On Error Resume Next</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">objFSO.CopyFile strSource, strTarget, True</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Rem everything below this line can be removed as this is for error checking</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">If Err.Number = 0 Then</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:small"><span style="font-family:Calibri"><span style="">                </span>Wscript.Echo &quot;File copied successfully&quot;</span></span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">Else</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:small"><span style="font-family:Calibri"><span style="">                </span>Wscript.Echo &quot;Error &quot; &amp; Err.Number &amp; vbTab &amp; Err.Description</span></span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-family:Calibri;font-size:small">End If</span></p>Sun, 05 Jul 2009 13:24:52 Z2009-07-05T13:24:52Z