Reputation: 117
Running a script that starts and kills/cleans two jobs via batch file before I package it for an EXE, works great in ISE elevated but immediately fails in console or command prompt with the following:
The code I have put together is here: https://pastebin.com/FWaZD249
It's really close to being done, basically, it's just a little script that checks the 5900 port for established connections, updates a form of a list of connections, and sends a little notification if someone new has connected, it runs on our print server computer which is screen-shared remotely via TightVNC, so operators don't get surprised when their mouse starts moving on them.
cmd batch code looks like this
powershell.exe -NoExit ". C:\Users\VS-Print-Server\Desktop\Userchecker.PS1"
Upvotes: 2
Views: 239
Reputation: 1999
As I mentioned in the comment: you initialize the jobs $job1
and job2
with $FormLib
respectively $LisLib
before those variables are set/initialized. Moving line 1 through 30 (everything before Write-Verbose -Verbose 'Before:'
) to the very end should make it work.
Upvotes: 1