Tray App no output

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Tray App no output

Post by apowershelluser »

I keep getting odd results with my loops

I'm checking for my flash drive named sapien
I'm checking if PowerShell Studio is running

Then continuing on.... sometimes, even if the USB drive was insterted before starting the app, will not detect it... Sometimes if PowerShell Studio is closed, it will say it's open.
Kompressor_Share.ps1
(1.86 KiB) Downloaded 105 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Tray App no output

Post by jvierra »

You are not checking for the USB in any way. Where are you doing this?
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Tray App no output

Post by apowershelluser »

Line 7

Then line 27 start the do while block
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Tray App no output

Post by jvierra »

How does that check for a new USB drive. It just test a non-existent variable.
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Tray App no output

Post by apowershelluser »

So my thinking is this..

Line 7, if it pulls the drive letter, means it's not $null, so we can skip that. If it is $null, it stops and does this until it finds the drive
  1. #Check USB status
  2. Do
  3. {
  4.     New-BurntToastNotification -Text "Flash Drive is not present" -AppLogo $ErrorLogo -Silent
  5.     start-sleep -Seconds 30
  6.     $USB
  7. }
  8. While ($USB -eq $null)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Tray App no output

Post by jvierra »

How does that get $usb to have a value? If $usb is null it will always be null.
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Tray App no output

Post by apowershelluser »

Line 7

Then in the while loop, if I put in my flash drive, it should detect that.... my thinking
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Tray App no output

Post by jvierra »

How would it detect it? How would the $usb variable get updated?
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Tray App no output

Post by apowershelluser »

Ooooooo. I need to call it within the check usb status loop???
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Tray App no output

Post by jvierra »

Code: Select all

while(-not ($USB = Get-PSDrive|?{$_.Description -eq 'Sapien'})){
	New-BurntToastNotification -Text "Flash Drive is not present" -AppLogo $ErrorLogo -Silent
	start-sleep -Seconds 10
}
This topic is 4 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked