{"action":"created","issue":{"url":"https://api.github.com/repos/nickrod518/PowerShell-Scripts/issues/2","repository_url":"https://api.github.com/repos/nickrod518/PowerShell-Scripts","labels_url":"https://api.github.com/repos/nickrod518/PowerShell-Scripts/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/nickrod518/PowerShell-Scripts/issues/2/comments","events_url":"https://api.github.com/repos/nickrod518/PowerShell-Scripts/issues/2/events","html_url":"https://github.com/nickrod518/PowerShell-Scripts/issues/2","id":146439226,"number":2,"title":"Finding 'exe' directory (Windows Server OS)","user":{"login":"j-sabrsula","id":11077362,"avatar_url":"https://avatars.githubusercontent.com/u/11077362?v=3","gravatar_id":"","url":"https://api.github.com/users/j-sabrsula","html_url":"https://github.com/j-sabrsula","followers_url":"https://api.github.com/users/j-sabrsula/followers","following_url":"https://api.github.com/users/j-sabrsula/following{/other_user}","gists_url":"https://api.github.com/users/j-sabrsula/gists{/gist_id}","starred_url":"https://api.github.com/users/j-sabrsula/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j-sabrsula/subscriptions","organizations_url":"https://api.github.com/users/j-sabrsula/orgs","repos_url":"https://api.github.com/users/j-sabrsula/repos","events_url":"https://api.github.com/users/j-sabrsula/events{/privacy}","received_events_url":"https://api.github.com/users/j-sabrsula/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-06T21:22:14Z","updated_at":"2016-04-19T18:06:22Z","closed_at":null,"body":"This may not be an issue so much as unexpected behavior for the lay person- \r\n\r\nOS: Windows Server 2012 R2\r\nPowershell version: 4\r\nIssue: Using the variable $PSScriptRoot in the powershell script before exe wrapping (the system variable normally stores root directory where script is executed from). \r\nExpected behavior: Variable stores path where powershell file is ran from (which works, but not as you'd think).\r\nObserved behavior: Variable stores temp variable path where exe extracts to, under C:\\Users\\<user>\\AppData\\Local\\Temp\\2\\IXP001.TMP\\. (also where powershell file is found and left there after the exe completes). \r\n\r\nIdeally this copied ps1 file would be cleaned up by the exe once the process completes, i'd imagine. \r\n\r\nHaving a way to reference where the exe ran from inside the powershell script would be nice as well, but I can't imagine a powershell script can talk outside the exe's scope. \r\nRunning [Reflection.Assembly]::GetExecutingAssembly().Location displays a 'blank' in the location field as well. \r\n\r\nScript to test:\r\n![image](https://cloud.githubusercontent.com/assets/11077362/14333279/77dd2a8e-fc13-11e5-8aa9-6d2af48fb233.png)\r\n\r\nOutput (log files removed up):\r\n![image](https://cloud.githubusercontent.com/assets/11077362/14333284/85c4bfc2-fc13-11e5-9515-f17ab0de0b28.png)\r\n"},"comment":{"url":"https://api.github.com/repos/nickrod518/PowerShell-Scripts/issues/comments/212048183","html_url":"https://github.com/nickrod518/PowerShell-Scripts/issues/2#issuecomment-212048183","issue_url":"https://api.github.com/repos/nickrod518/PowerShell-Scripts/issues/2","id":212048183,"user":{"login":"nickrod518","id":2184955,"avatar_url":"https://avatars.githubusercontent.com/u/2184955?v=3","gravatar_id":"","url":"https://api.github.com/users/nickrod518","html_url":"https://github.com/nickrod518","followers_url":"https://api.github.com/users/nickrod518/followers","following_url":"https://api.github.com/users/nickrod518/following{/other_user}","gists_url":"https://api.github.com/users/nickrod518/gists{/gist_id}","starred_url":"https://api.github.com/users/nickrod518/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickrod518/subscriptions","organizations_url":"https://api.github.com/users/nickrod518/orgs","repos_url":"https://api.github.com/users/nickrod518/repos","events_url":"https://api.github.com/users/nickrod518/events{/privacy}","received_events_url":"https://api.github.com/users/nickrod518/received_events","type":"User","site_admin":false},"created_at":"2016-04-19T18:06:22Z","updated_at":"2016-04-19T18:06:22Z","body":"The one issue I see with replacing $PSScriptRoot with the pseudo root of the exe is that if someone uses supplementary files with this tool, those can't be referenced by relative path anymore. I don't think it would be difficult to add the exe's path (%~dp0) as a parameter passed to your script, but you'd still have to add the logic in your script to accept and do something with that, know what I mean?"}}