Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

start-job does not give expected result

$
0
0

Good day,

I have below scripts and below outputs. But I dont understand the output. It is different than I expected. Can anyone explain it to me?

file_search.ps1

$fsw = New-Object System.IO.FileSystemWatcher  -Property @{
Path = "c:\" 
Filter ="*.ods"
IncludeSubdirectories = $true
}
$event = Register-ObjectEvent -InputObject $fsw –EventName Created -SourceIdentifier fsw2 -Action { 
	    if(Test-Path -Path $EventArgs.FullPath -PathType Leaf )
	    {
			Start-Job -FilePath c:\delete_file2.ps1 -ArgumentList $EventArgs.FullPath
	    }	
}


delete_file2.ps1

$temp = "$(Get-Date) " + $args[0] + " came to delete "
$temp | Out-File -FilePath c:\delete.txt -Append

$file = $args[0]
Start-Job -FilePath c:\show_msg.ps1 -ArgumentList $file
do
{
remove-item $file -Force
}
while (Test-Path $file)

$temp = "$(Get-Date) " + $args[0] + " exit from delete "
$temp | Out-File -FilePath c:\delete.txt -Append


show_msg.ps1

$temp2 = "$(Get-Date) " + $args[0] + " came to show_msg "
$temp2 | Out-File -FilePath c:\show.txt -Append

$a = New-Object -comobject wscript.shell
$b = $a.popup("Sorry, you can't save .ods files on your local disk.`r`n",0,"IT Department",0)

$temp2 = "$(Get-Date) " + $args[0] + " exit from show_msg "
$temp2 | Out-File -FilePath c:\show.txt -Append

AND OUTPUTS ARE

delete.txt

10/12/2012 16:31:17 c:\VirtualBox-4.1.22-80657-Win.ods came to delete  
10/12/2012 16:31:21 c:\VirtualBox-4.1.22-80657-Win.ods exit from delete 
10/12/2012 16:31:21 c:\PowerGUI.3.2.0.2237.ods came to delete  
10/12/2012 16:31:22 c:\New OpenDocument Spreadsheet.ods came to delete  
10/12/2012 16:31:22 c:\PowerGUI.3.2.0.2237.ods exit from delete 
10/12/2012 16:31:23 c:\New OpenDocument Spreadsheet.ods exit from delete 
10/12/2012 16:31:24 c:\FileFormatConverters(1).ods came to delete  
10/12/2012 16:31:24 c:\FileFormatConverters(1).ods exit from delete 
10/12/2012 16:31:25 c:\erg.ods came to delete  
10/12/2012 16:31:25 c:\asd.ods came to delete  
10/12/2012 16:31:25 c:\erg.ods exit from delete 
10/12/2012 16:31:25 c:\asd.ods exit from delete 

show.txt


10/12/2012 16:31:18 c:\VirtualBox-4.1.22-80657-Win.ods came to show_msg 
10/12/2012 16:31:18 c:\VirtualBox-4.1.22-80657-Win.ods exit from show_msg 
10/12/2012 16:31:23 c:\PowerGUI.3.2.0.2237.ods came to show_msg 
10/12/2012 16:31:23 c:\PowerGUI.3.2.0.2237.ods exit from show_msg 
10/12/2012 16:31:23 c:\New OpenDocument Spreadsheet.ods came to show_msg 
10/12/2012 16:31:23 c:\New OpenDocument Spreadsheet.ods exit from show_msg 
10/12/2012 16:31:25 c:\FileFormatConverters(1).ods came to show_msg 
10/12/2012 16:31:25 c:\FileFormatConverters(1).ods exit from show_msg 

in delete.txt there are 12 lines of output which is ok, but in show.txt there are 8 of them which is I dont understand

no popup screen appears in the screen which is inclueded in show_msg.ps1

it is friday 16:37 here and I have to finish this until 17:30

help please...


Viewing all articles
Browse latest Browse all 2562

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>