0

I'm having a little problem with a script (thanks for the script, sir Jubjub Bandersnatch) that is not running as intended. The script is intended to define an execution policy for the OS and, after setting it, executing a .ps1 script wich intalls IIS 7.0.

cls
Powershell -noexit -command "& {Set-ExecutionPolicy remotesigned -Force}"
Powershell -File c:\ScriptsIIS\IISInstallation.ps1

The problem is, it sets an Execution policy with success but after it, the script won't open the .ps1 file. And, another thing that I thought of, people in the company will download this script to different locations, and how do I set a generalized desktop? Like, I'll put a guide together with the files asking to extract the files on desktop, but how can I tell the script the files will be on their desktop (read: diferent users will need this) without having to modify the script?

EDIT1: The first problem was solved with a simple " Start " in front of each line. And I think I might solve the second problem just putting:

powershell -file c:\Users\%Username%\Desktop\ScriptsIIS\IISInstallation.ps1

EDIT2: I was right, the " %USERNAME% solved it.

6
  • ` cls Powershell -noexit -command "& {Set-ExecutionPolicy remotesigned -Force}" powershell -file c:\Users\%Username%\Desktop\ScriptsIIS\IISInstallation.ps1 ` worked ^^ Commented Jun 26, 2013 at 18:48
  • I think you should remove -noexit from the first line Commented Jun 26, 2013 at 19:23
  • Done it, now we don't have a cmd window after doing what we needed to do. Thanks ^^ Commented Jun 26, 2013 at 20:08
  • Two suggestions. 1. If you want to set an ExecutionPolicy for all users and you have an Active Directory domain, you should set it using Group Policy, unless you want users to be able to later change to setting you give them. If it's defined by GP, not only are the changes propagated more reliably, users can't change it. 2. For the path of the Desktop, use %homepath%\Desktop instead of C:\Users\%username%\Desktop. That will work across different versions of Windows. Microsoft has changed the default location of user profiles a couple of times.
    – Adi Inbar
    Commented Jun 26, 2013 at 22:34
  • If you don't want to set the machine's ExecutionPolicy permanently you can launch powershell with -ExecutionPolicy remoteSigned. May make more sense if your organization is sensitive about what users can do on their desktops.
    – Χpẘ
    Commented Jun 27, 2013 at 2:17

1 Answer 1

0

(Question solved by OP edits. See Question with no answers, but issue solved in the comments (or extended in chat) )

The OP wrote:

EDIT1: The first problem was solved with a simple " Start " in front of each line. And I think I might solve the second problem just putting:

powershell -file c:\Users\%Username%\Desktop\ScriptsIIS\IISInstallation.ps1

EDIT2: I was right, the " %USERNAME% solved it.

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.