{"id":38,"date":"2002-08-08T12:12:37","date_gmt":"2002-08-08T16:12:37","guid":{"rendered":"http:\/\/wordpress.cephas.net\/?p=38"},"modified":"2002-08-08T12:12:37","modified_gmt":"2002-08-08T16:12:37","slug":"wsh-for-windows-automation","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2002\/08\/08\/wsh-for-windows-automation\/","title":{"rendered":"wsh for windows automation"},"content":{"rendered":"<p>Follow up to last night&#8217;s post on wget.  The wget app (in my case) needs to run every couple hours during the day.  Windows 2000 and higher has a built task scheduler which I could (and will) use to schedule the execution of the task, but to do this I&#8217;d have to type some kludgy command line arguments AND I&#8217;d have to have administrator access to the machine in order to change any of the properties of the task.  There must be a better way&#8230; enter Windows Script files(.wsf), which is &#8220;.. a text document containing Extensible Markup Language (XML) code, incorporates several features that offer you increased scripting flexibility. (from <a href=\"http:\/\/msdn.microsoft.com\/archive\/default.asp?url=\/archive\/en-us\/wsh\/htm\/wsAdvantagesOfWs.asp\">MSDN<\/a>).  It&#8217;s kinda like <a href=\"http:\/\/jakarta.apache.org\/ant\/\">ANT<\/a>, except Windows specific.<\/p>\n<p>My download wget script eventually looks like this:<\/p>\n<p><!-- Filename: wget.wsf--><\/p>\n<p>        http:\/\/someserver.com\/myxmlpacket2.xml.gz<\/p>\n<p>        FileName.xml.gz<\/p>\n<p>        http:\/\/someserver.com\/myxmlpacket.xml.gz<\/p>\n<p>        theNameofMyFile.xml.gz<\/p>\n<p>\nCouple things to notice: a) a wsf is valid xml, b) you can run multiple jobs in one file, and c) you can reuse your existing VBS scripts.  So now, seeing my wsf file, how would I call that using the Windows Task Scheduler? You want to run cscript.exe, which is in c:\\$winnt$\\system32\\, so you&#8217;re run command would look like this:<\/p>\n<p>C:\\WINNT\\system32\\cscript.exe \/\/Job:daypart c:\\wget\\wget.wsf <\/p>\n<p>where &#8216;daypart&#8217; is the name of the job within your wget.wsf file.  Using WSF as a wrapper for the wget executable allows you to easily tasks to a specific jobs. Even better, you can access almost anything on a Windows system or network using VBScript\/WSH, including <a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/script56\/html\/wsconAccessingNetworkConnections.asp?frame=true\">accessing network connections<\/a>, <a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/script56\/html\/wsconAccessingNetworkConnections.asp?frame=true\">creating local applications<\/a>, and <a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/script56\/html\/wsconManipulatingSystemRegistryProgrammatically.asp?frame=true\">managing the system registry<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Follow up to last night&#8217;s post on wget. The wget app (in my case) needs to run every couple hours during the day. Windows 2000 and higher has a built task scheduler which I could (and will) use to schedule the execution of the task, but to do this I&#8217;d have to type some kludgy &hellip; <a href=\"https:\/\/cephas.net\/blog\/2002\/08\/08\/wsh-for-windows-automation\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">wsh for windows automation<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/38"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}