Git Product home page Git Product logo

Comments (7)

MScholtes avatar MScholtes commented on August 16, 2024

Hello princdoberman,

according to the exception message this is no issue with PSEXE, $PathMyFolder seems to be empty.

Perhaps you have stumbled across the topic of script variables? Then see the remarks to this on the readme page of this repository.

Greetings

Markus

from ps2exe.

princdoberman avatar princdoberman commented on August 16, 2024

As I said earlier ...
ps1 script is executed without error from PowerShell.

But when I compile in .exe ... got error "Path cannot be empty string ..."
It looks like .exe can't retrieve path.

from ps2exe.

princdoberman avatar princdoberman commented on August 16, 2024

you can try put that at test.ps1 and compile to .exe:

$MyTime = $(((get-date).ToLocalTime()).ToString("yyyyMMddT_HHmmssZ"))
$MyFolder = $env:COMPUTERNAME
$PathMyFolder = Join-Path $PSScriptRoot $MyFolder
[System.IO.Directory]::CreateDirectory($PathMyFolder)
$txtName = "$MyTime.txt"
$txtbase = Join-Path $PathMyFolder $txtName

Get-WmiObject -Class Win32_ComputerSystem | out-file $txtbase -Encoding utf8 -Append

from ps2exe.

MScholtes avatar MScholtes commented on August 16, 2024

Would you please read my answer. The issue and the solution is explained there!

from ps2exe.

princdoberman avatar princdoberman commented on August 16, 2024

I apologize, but I don't understand.
Maybe I don't know the PowerShell enough or don't understanding the language since English is not my native language.
From your answer I can't find any tip/clue to solution.
You think I've got something wrong with the variables? ( everything with variables work in native ps1 script )
On which remark of this repository you think ?

from ps2exe.

MScholtes avatar MScholtes commented on August 16, 2024

OK:
You are using the variable $PSScriptRoot to get the directory of the script.
When you compile your script to an executable it is no script anymore so this variable is empty.
This leads to your error.

Please look at the readme page of this repository (the web page you get when you go to the repository in your browser). There is a paragraph Remarks with a subparagraph Script variables:. Here a possible solution is presented.

Greetings

Markus

from ps2exe.

princdoberman avatar princdoberman commented on August 16, 2024

Sorry ... I find on tab Wiki...
Remarks ...
Script variables .... Especially the variable $PSScriptRoot is empty.

Thanks.

from ps2exe.

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.