{"id":861,"date":"2015-05-26T23:23:48","date_gmt":"2015-05-26T21:23:48","guid":{"rendered":"http:\/\/www.netexpertise.eu\/en\/?p=861"},"modified":"2021-04-23T17:37:30","modified_gmt":"2021-04-23T15:37:30","slug":"run-as400-sessions-on-windows-startup","status":"publish","type":"post","link":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html","title":{"rendered":"Run AS400 Session on Windows Startup"},"content":{"rendered":"\n<p>You may need to launch AS400 sessions at boot for various reasons such as automated scripts or print sessions. Here are a few pitfalls you may encounter.<br><br>First of all, sessions wouldn&#8217;t launch without pcsws.exe extra parameters \/H &#8211; for Hidden &#8211; and eventually \/Q &#8211; to hide the IBM popup window. pcsws.exe options are all listed on <a href=\"http:\/\/www-01.ibm.com\/support\/knowledgecenter\/SSEQ5Y_5.9.0\/com.ibm.pcomm.doc\/books\/html\/quick_beginnings09.htm\">IBM<\/a> for reference.<br><br>This will work for a single session. In order to deal with 2 or more sessions, they have to be launched with the &#8220;start&#8221; command. Add \/B parameter to hide the DOS command window followed by &#8220;&#8221;, or the main command parameters will be being ignored.<br><br>This makes me come up with the following simple batch.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">@echo off\n\nSet ScriptPath=C:\\Scripts\nSet client_Access_Home=C:\\Program Files (x86)\\IBM\\Client Access\nSet AS400=My_iSeries_Host\nSet iSeries_User=myUser\nSet password=myPassword\n\n\"%client_Access_Home%\\cwblogon.exe\" %AS400% \/u %iSeries_User% \/p \"%password%\"\n\nstart \/B \"\" \"%client_Access_Home%\\Emulator\\pcsws.exe\" %ScriptPath%\\session.ws \/Q \/H\nstart \/B \"\" \"%client_Access_Home%\\Emulator\\pcsws.exe\" %ScriptPath%\\other_session.ws \/Q \/H\n\npause<\/code><\/pre>\n\n\n\n<p><br>Create a new entry in the task scheduler to be run at server boot.<br>Select the user it should be run under and tick &#8220;Run whether user is logged on or not&#8221; and set the bat file defined above under Actions.<br><br>The &#8220;pause&#8221; command is mandatory. If removed, the task will end, the cmd process shuts leaving the pcsws.exe processes up but orphans. The printer writer will remain in the END state on <a href=\"\/en\/tag\/ibm-i\">IBM i<\/a> !<br>If anybody has a clue as to why, please leave a comment.<br>cwblogon.exe is far from ideal on the security side, it is best to define a restricted profile! Set the same user in iSeries Navigator or in the session parameters.<br><br>This was tested on Windows Server 2012. I have no clue if it works on other OS but there&#8217;s no reason why it would not.<br>You can now schedule reboots anytime you like without having to deal with starting sessions manually.<br><br>For printer sessions though, you&#8217;re better off printing to a <a href=\"\/en\/as400\/as400-printing-windows-printer-share.html\">Windows printer share<\/a>. It&#8217;s probably a better and cleaner way to do it.<br>You can connect with <a href=\"\/en\/systems\/as400\/ssh-default-shell-and-command-history-on-as400.html\">SSH<\/a> protocol if you want to run shell scripts or CL programs (with the &#8220;system&#8221; command) and do many other things.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may need to launch AS400 sessions at boot for various reasons such as automated scripts or print sessions. Here are a few pitfalls you may encounter. First of all, sessions wouldn&#8217;t launch without pcsws.exe extra parameters \/H &#8211; for Hidden &#8211; and eventually \/Q &#8211; to hide the IBM popup window. pcsws.exe options are [&hellip;]<\/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},"categories":[210],"tags":[396,405,230],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Netexpertise - Run AS400 Session on Windows Startup<\/title>\n<meta name=\"description\" content=\"You want to run AS400 sessions on Windows startup for various reasons such as automated scripts or print sessions. Here are a few pitfalls you may encounter.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Netexpertise - Run AS400 Session on Windows Startup\" \/>\n<meta property=\"og:description\" content=\"You want to run AS400 sessions on Windows startup for various reasons such as automated scripts or print sessions. Here are a few pitfalls you may encounter.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html\" \/>\n<meta property=\"og:site_name\" content=\"Netexpertise\" \/>\n<meta property=\"article:published_time\" content=\"2015-05-26T21:23:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-23T15:37:30+00:00\" \/>\n<meta name=\"author\" content=\"dave\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@netexpertise\" \/>\n<meta name=\"twitter:site\" content=\"@netexpertise\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html\",\"name\":\"Netexpertise - Run AS400 Session on Windows Startup\",\"isPartOf\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#website\"},\"datePublished\":\"2015-05-26T21:23:48+00:00\",\"dateModified\":\"2021-04-23T15:37:30+00:00\",\"author\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\"},\"description\":\"You want to run AS400 sessions on Windows startup for various reasons such as automated scripts or print sessions. Here are a few pitfalls you may encounter.\",\"breadcrumb\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.netexpertise.eu\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Run AS400 Session on Windows Startup\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#website\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/\",\"name\":\"Netexpertise\",\"description\":\"Systems \/ Networks \/ DevOps\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.netexpertise.eu\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\",\"name\":\"dave\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"caption\":\"dave\"},\"sameAs\":[\"http:\/\/www.netexpertise.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Netexpertise - Run AS400 Session on Windows Startup","description":"You want to run AS400 sessions on Windows startup for various reasons such as automated scripts or print sessions. Here are a few pitfalls you may encounter.","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":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html","og_locale":"en_US","og_type":"article","og_title":"Netexpertise - Run AS400 Session on Windows Startup","og_description":"You want to run AS400 sessions on Windows startup for various reasons such as automated scripts or print sessions. Here are a few pitfalls you may encounter.","og_url":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html","og_site_name":"Netexpertise","article_published_time":"2015-05-26T21:23:48+00:00","article_modified_time":"2021-04-23T15:37:30+00:00","author":"dave","twitter_card":"summary_large_image","twitter_creator":"@netexpertise","twitter_site":"@netexpertise","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html","url":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html","name":"Netexpertise - Run AS400 Session on Windows Startup","isPartOf":{"@id":"http:\/\/www.netexpertise.eu\/en\/#website"},"datePublished":"2015-05-26T21:23:48+00:00","dateModified":"2021-04-23T15:37:30+00:00","author":{"@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa"},"description":"You want to run AS400 sessions on Windows startup for various reasons such as automated scripts or print sessions. Here are a few pitfalls you may encounter.","breadcrumb":{"@id":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.netexpertise.eu\/en\/systems\/as400\/run-as400-sessions-on-windows-startup.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.netexpertise.eu\/en"},{"@type":"ListItem","position":2,"name":"Run AS400 Session on Windows Startup"}]},{"@type":"WebSite","@id":"http:\/\/www.netexpertise.eu\/en\/#website","url":"http:\/\/www.netexpertise.eu\/en\/","name":"Netexpertise","description":"Systems \/ Networks \/ DevOps","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.netexpertise.eu\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa","name":"dave","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","caption":"dave"},"sameAs":["http:\/\/www.netexpertise.eu"]}]}},"_links":{"self":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/861"}],"collection":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/comments?post=861"}],"version-history":[{"count":0,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/861\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/media?parent=861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/categories?post=861"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/tags?post=861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}