1

it runs the script up until the if clause (for running url) I cannot include the other url here but the script is

"welcome, want to go to site?"

$goyn=read-host -prompt "enter y or n"

if($goyn -eq 'y'){
start-process -Filepath chrome.exe -ArgumentList www.google.ca
}
else{"continue on your journey of awesomeness"}


Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Get-WmiObject -Class Win32_OperatingSystem -ComputerName localhost |
Select-Object -Property CSName,@{n="Last Booted";
e={[Management.ManagementDateTimeConverter]::ToDateTime($_.LastBootUpTime)}}

for the start-process it throws the error "cannot find file specified followed by the path for $profile. wanted a quicker way of of getting to my work service page.

2
  • 1
    Powershell generally requires full paths for referenced files. Commented Jul 18, 2016 at 20:52
  • specified the full path and it still throws the error (using the path for iexplorer instead as that is the browser for the other computers on network) seems to have issue with start-process maybe? Commented Jul 18, 2016 at 21:40

2 Answers 2

1

Specify full path to chrome.exe and other used items. E.g. C:\Program Files (x86)\Google\Application\chrome.exe. Adjust %PATH% otherwise. But I'd better specify full path.

Sign up to request clarification or add additional context in comments.

Comments

0

So figured it out. it did not like start-process not one bit no matter how outrageously obvious I made the path. So I used the start cmdlet instead and put site in single quotes. Code looks like this:

"welcome, want to go to site?"

$goyn=read-host -prompt "enter y or n"

if($goyn -eq 'y'){
start 'www.google.ca'
}
else{"continue on your journey of awesomeness"}


Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Get-WmiObject -Class Win32_OperatingSystem -ComputerName localhost |
Select-Object -Property CSName,@{n="Last Booted";
e={[Management.ManagementDateTimeConverter]::ToDateTime($_.LastBootUpTime)}}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.