Apologies if this is a really simple thing, but I really struggle at understanding coding so I’m hoping someone can help me. I have the relatively simple Powershell script. It seems to run, but for the output I get this Stderr log message. If someone could let me know how to correct it I would appreciate it.
'$varArgs' : The term ''$varArgs'' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:ProgramDataCentraStagePackages2bc7843b-1d71-4c43-bb6a-1ececfde5a61#command.ps1:25 char:18
+ $varArgs=`'$varArgs`'
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: ('$varArgs':String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Here is the script:
# If you are reading this, you have copied the Component successfully,
# probably for the purposes of attaching your own configuration file.
# Near the bottom of this page, attach your .bgi file to the Component
# and then save the Component with a new name. The script will identify
# the presence of the file and alter the startup routines to use it.
# ----------------------------------------------------------------------
# BGInfo installer/implanter :: build 17/seagull december 2020 :: thanks to michael mccool
write-host "Install and configure BGInfo to run on Startup"
write-host "============================================="
# install the executable somewhere we can bank on its presence
new-item -Path "$env:tempBGInfo" -ItemType Directory -Force | Out-Null
Move-Item bginfo4.exe "$env:tempBGInfo" -Force
Move-Item bginfo8.exe "$env:tempBGInfo" -Force
# check for BGIs
if (!(test-path *.bgi)) {
write-host "- ERROR: There needs to be at least one .bgi file for the Component to work."
write-host " Execution cannot continue. Exiting."
exit 1
} else {
if (test-path *.bgi -exclude default.bgi) {
$varArgs=(ls *.bgi -Exclude default.bgi | Select-Object -First 1).Name
$varArgs=`'$varArgs`'
} else {
$varArgs='default.bgi'
}
}
Move-Item $varArgs "$env:tempBGInfo" -Force
# furnish a quick CMD script
set-content "$env:ProgramDataMicrosoftWindowsStart MenuProgramsStartupBGILaunch.cmd" -value '@echo off'
add-content "$env:ProgramDataMicrosoftWindowsStart MenuProgramsStartupBGILaunch.cmd" -value "$env:tempBGInfobginfo$([intptr]::Size).exe `"$env:tempBGInfo$varArgs`" /silent /nolicprompt /timer:0"
# add-content "$env:ProgramDataMicrosoftWindowsStart MenuProgramsStartupBGILaunch.cmd" -value 'echo Please wait -- Configuring wallpaper'
# add-content "$env:ProgramDataMicrosoftWindowsStart MenuProgramsStartupBGILaunch.cmd" -value "ping -n 5 127.0.0.1 > nul"
# inform the user
# write-host "- BGInfo has been installed and configured to run on Startup."
# write-host " Endpoints will need to be rebooted for changes to take effect."