Jump to content
Ketarin forum

Powershell: use global variable before updating


cybermcm
 Share

Recommended Posts

I'm trying the following:
define a global variable, e.g. "7zip"
create a PowerShell "before updating" global command: "$7zip = $GlobalVars.'7zip'.CachedContent"
then try using this in a PowerShell command "after downloading":  $7zip x c:\temp\test.zip

This is not working, it seems that $7zip is not defined when "after downloading" script is executed.

Any ideas how to solve that? Putting "$7zip = $GlobalVars.'7zip'.CachedContent" within the "after download" section works but then I'd have to put it in every application which I want  to avoid...

Link to comment
Share on other sites

Two issues I see.

1) I think you're confusing the Ketarin term "global variable" with PowerShell variables.

2) PowerShell scripts are self-contained - they don't exist outside of themselves and any values you want to use within a script need to be extracted within the script itself.

However, to address your problem I recommend just adding the folder your 7zip executable is in (or the folder Ketarin resides within) to the PATH variable so you can avoid the problem completely. We've had similar issues like this in the past and I know many of us have added our Ketarin folders to the PATH and we just put our utilities in the same folder as Ketarin. 

Link to comment
Share on other sites

thx @shawn for your answer.

1) no I got it right, my example isn't described enough, I assume I know the difference

2) this explains why it isn't working and was already coming to my mind that the scripts are running for themselves

and thx again for a possible workaround addressing my issue

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.