Giter Site home page Giter Site logo

Comments (7)

Disassembler0 avatar Disassembler0 commented on August 27, 2024

Weird. In the past, there was a problem with current working directory getting lost during elevation, resulting in wrongly resolved relative paths, but that has been fixed in d427ae7.

I'm using the presets in bat scripts normally, see eg. Win10-ApplyAll.bat from test folder.

Could you give me a specific example of your bat file?

from win10-initial-setup-script.

voshond avatar voshond commented on August 27, 2024

@echo OFF

powershell.exe -NoProfile -ExecutionPolicy Bypass -File "Win10.ps1" -preset "Win10-Personal.preset"

All Files, Win10, the preset and the bat are in the same folder.
Double checked if they were there and renamed correctly.

I'm trying this stuff out:

https://stackoverflow.com/questions/22490785/powershell-run-script-from-shortcut-using-relative-path

from win10-initial-setup-script.

Disassembler0 avatar Disassembler0 commented on August 27, 2024

Ah, I see. That's probably just PowerShell being PowerShell. Try

powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\Win10.ps1" -preset "Win10-Personal.preset"

from win10-initial-setup-script.

voshond avatar voshond commented on August 27, 2024

do i need .\ for the argument as well?
trying in a sec

from win10-initial-setup-script.

voshond avatar voshond commented on August 27, 2024

Works.

oddly when i use this method to run other scripts as well, it works.
As soon as i run the script as admin it doesnt, any clues?
trying to run this one: https://github.com/W4RH4WK/Debloat-Windows-10/blob/master/utils/install-basic-software.ps1

from win10-initial-setup-script.

voshond avatar voshond commented on August 27, 2024

you had some "require admin" magic in there, is it because of that?

from win10-initial-setup-script.

Disassembler0 avatar Disassembler0 commented on August 27, 2024

As it turns out you actually don't need to put .\ if you have it in the -File argument (which you do have). Only if you'd use just powershell.exe Win10.ps1 (without -File) then you'd need to supply also .\ otherwise you get

Win10.ps1 : The term 'Win10.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program.

However I've tried just now with your line without .\ and it works for me on clean Win10 Pro 1709 (16299.125).

The other error which you might be getting is

The argument 'Win10.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.

Which you'll get when you try to launch the script while you are in different directory than the Win10.ps1 and the preset are, because the relative paths are resolved against the current working directory.

Which error are you getting?

you had some "require admin" magic in there, is it because of that?

RequireAdmin magic is used for the auto-elevation. Regarding the presets, it just takes the relative path to the preset, resolves it and reinject as absolute path to the elevated script to prevent the error mentioned above.

from win10-initial-setup-script.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.