{"id":13,"date":"2006-10-25T11:55:34","date_gmt":"2006-10-25T11:55:34","guid":{"rendered":"http:\/\/parkesy.wordpress.com\/2006\/10\/25\/doh\/"},"modified":"2006-10-25T11:55:34","modified_gmt":"2006-10-25T11:55:34","slug":"doh","status":"publish","type":"post","link":"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/","title":{"rendered":"Doh!"},"content":{"rendered":"<p>Ever feel stupid?<\/p>\n<p>I have a vbscript that copies a series of files from one server to another (don&#8217;t ask why!) that runs using a scheduled task<\/p>\n<p>Now if i run the script manually all works fine. If i run the scheduled task manually all works fine.<\/p>\n<p>However, every week when i expect the data to have been copied nothing happens<\/p>\n<p>I&#8217;ve simplified the code for posting purposes as the code also does some logging and error checking<\/p>\n<p><em>SourceFolderPath = &#8220;S:\\Images\\System\\&#8221;<br \/>\nDestinationFolderPath =&#8221;E:\\images\\TempArea\\&#8221;\u00a0<\/em><\/p>\n<p><em>set FSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<\/em><\/p>\n<p><em>set SourceFolderObj = FSO.GetFolder(SourceFolderPath)<br \/>\nSet DestinationFolderObj = FSO.GetFolder(DestinationFolderPath)<br \/>\n&#8221;Empty Destination Directory <\/em><\/p>\n<p><em>For each  LoopFile in DestinationFolderObj.Files<br \/>\nLoopName = LoopFile.name<br \/>\nLoopFile.Delete<br \/>\n<\/em><em>next <\/em><\/p>\n<p><em>\u00a0&#8221;Transfer files<\/em><\/p>\n<p><em>For each LoopFile in SourceFolderObj.Files<\/em><\/p>\n<p><em>LoopFile.Copy(DestinationFolderPath)<\/em><\/p>\n<p><em>Next <\/em><\/p>\n<p>Can anyone tell me why this fails?<\/p>\n<p>I had a eureka moment this morning<\/p>\n<p>The source folder is on drive S:<\/p>\n<p>Which exists when i run the script manually. But it doesn&#8217;t exist when i&#8217;m logged off<\/p>\n<p>So i added the following<\/p>\n<p><em>strDriveLetter = &#8220;S:&#8221;<br \/>\nstrRemotePath = &#8220;\\\\Server\\Share<br \/>\nstrUser = &#8220;someuser&#8221;<br \/>\nstrPassword = &#8220;somepassword&#8221;\u00a0\u00a0\u00a0\u00a0\u00a0<br \/>\nstrProfile = &#8220;false&#8221;<\/em><\/p>\n<p><em>Set objNetwork = WScript.CreateObject(&#8220;WScript.Network&#8221;)<br \/>\nobjNetwork.MapNetworkDrive strDriveLetter, strRemotePath,strProfile, strUser, strPassword<\/em><\/p>\n<p>And volia!<\/p>\n<p>Not entirely sure why i didn&#8217;t spot this earlier but needless to say when i did i felt like giving myself a kick!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever feel stupid? I have a vbscript that copies a series of files from one server to another (don&#8217;t ask why!) that runs using a scheduled task Now if i run the script manually all works fine. If i run the scheduled task manually all works fine. However, every week when i expect the data<\/p>\n<p><a class=\"readmore\" href=\"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/\"><span class=\"arrow-right icon\"><\/span>Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[42],"tags":[],"class_list":["post-13","post","type-post","status-publish","format-standard","hentry","category-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.11 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Doh! - Andy&#039;s Techie Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Doh! - Andy&#039;s Techie Blog\" \/>\n<meta property=\"og:description\" content=\"Ever feel stupid? I have a vbscript that copies a series of files from one server to another (don&#8217;t ask why!) that runs using a scheduled task Now if i run the script manually all works fine. If i run the scheduled task manually all works fine. However, every week when i expect the dataRead More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/\" \/>\n<meta property=\"og:site_name\" content=\"Andy&#039;s Techie Blog\" \/>\n<meta property=\"article:published_time\" content=\"2006-10-25T11:55:34+00:00\" \/>\n<meta name=\"author\" content=\"Andy Parkes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Andy Parkes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/\",\"url\":\"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/\",\"name\":\"Doh! - Andy&#039;s Techie Blog\",\"isPartOf\":{\"@id\":\"https:\/\/andyparkes.co.uk\/blog\/#website\"},\"datePublished\":\"2006-10-25T11:55:34+00:00\",\"dateModified\":\"2006-10-25T11:55:34+00:00\",\"author\":{\"@id\":\"https:\/\/andyparkes.co.uk\/blog\/#\/schema\/person\/3534e8ac6b1bec765cd061feff56679d\"},\"breadcrumb\":{\"@id\":\"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/andyparkes.co.uk\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Doh!\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/andyparkes.co.uk\/blog\/#website\",\"url\":\"https:\/\/andyparkes.co.uk\/blog\/\",\"name\":\"Andy&#039;s Techie Blog\",\"description\":\"Professional Geek\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/andyparkes.co.uk\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/andyparkes.co.uk\/blog\/#\/schema\/person\/3534e8ac6b1bec765cd061feff56679d\",\"name\":\"Andy Parkes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/andyparkes.co.uk\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3824cbf53df51d7ca5cf809b6ad81a157fbfff2292e36ab8666f04ddad06bfcc?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3824cbf53df51d7ca5cf809b6ad81a157fbfff2292e36ab8666f04ddad06bfcc?s=96&d=mm&r=g\",\"caption\":\"Andy Parkes\"},\"description\":\"Andy Parkes is Technical Director at Coventry based IT support company IBIT Solutions. Formerly, coordinator of AMITPRO and Microsoft Partner Area Lead for 2012-2013. He also isn't a fan of describing himself in the third person.\",\"sameAs\":[\"http:\/\/www.andyparkes.co.uk\/blog\"],\"url\":\"https:\/\/andyparkes.co.uk\/blog\/index.php\/author\/andyparkes\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Doh! - Andy&#039;s Techie Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/","og_locale":"en_US","og_type":"article","og_title":"Doh! - Andy&#039;s Techie Blog","og_description":"Ever feel stupid? I have a vbscript that copies a series of files from one server to another (don&#8217;t ask why!) that runs using a scheduled task Now if i run the script manually all works fine. If i run the scheduled task manually all works fine. However, every week when i expect the dataRead More","og_url":"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/","og_site_name":"Andy&#039;s Techie Blog","article_published_time":"2006-10-25T11:55:34+00:00","author":"Andy Parkes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Andy Parkes","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/","url":"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/","name":"Doh! - Andy&#039;s Techie Blog","isPartOf":{"@id":"https:\/\/andyparkes.co.uk\/blog\/#website"},"datePublished":"2006-10-25T11:55:34+00:00","dateModified":"2006-10-25T11:55:34+00:00","author":{"@id":"https:\/\/andyparkes.co.uk\/blog\/#\/schema\/person\/3534e8ac6b1bec765cd061feff56679d"},"breadcrumb":{"@id":"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/andyparkes.co.uk\/blog\/index.php\/2006\/10\/25\/doh\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/andyparkes.co.uk\/blog\/"},{"@type":"ListItem","position":2,"name":"Doh!"}]},{"@type":"WebSite","@id":"https:\/\/andyparkes.co.uk\/blog\/#website","url":"https:\/\/andyparkes.co.uk\/blog\/","name":"Andy&#039;s Techie Blog","description":"Professional Geek","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/andyparkes.co.uk\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/andyparkes.co.uk\/blog\/#\/schema\/person\/3534e8ac6b1bec765cd061feff56679d","name":"Andy Parkes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/andyparkes.co.uk\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3824cbf53df51d7ca5cf809b6ad81a157fbfff2292e36ab8666f04ddad06bfcc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3824cbf53df51d7ca5cf809b6ad81a157fbfff2292e36ab8666f04ddad06bfcc?s=96&d=mm&r=g","caption":"Andy Parkes"},"description":"Andy Parkes is Technical Director at Coventry based IT support company IBIT Solutions. Formerly, coordinator of AMITPRO and Microsoft Partner Area Lead for 2012-2013. He also isn't a fan of describing himself in the third person.","sameAs":["http:\/\/www.andyparkes.co.uk\/blog"],"url":"https:\/\/andyparkes.co.uk\/blog\/index.php\/author\/andyparkes\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/smvJ6-doh","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/andyparkes.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andyparkes.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andyparkes.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andyparkes.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/andyparkes.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=13"}],"version-history":[{"count":0,"href":"https:\/\/andyparkes.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/13\/revisions"}],"wp:attachment":[{"href":"https:\/\/andyparkes.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andyparkes.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andyparkes.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}