powershell - Check for file creation in a loop -


can run script 1 time automate when .exe show on folder?

get-childitem -filter *.exe | foreach {     &$_.fullname /s 

i want script check if .exe file shows on folder, run commands, else check again .exe file.

you can use filesystemwatcher listen these events.

get-eventsubscriber -sourceidentifier execreated -erroraction silentlycontinue | unregister-event; $watcher = new-object -typename system.io.filesystemwatcher; $watcher.filter = '*.exe'; $watcher.path = 'c:\test';  $action = { write-host -object ('new file created: {0}' -f $event.sourceargs[1].name); }; register-objectevent -inputobject $watcher -eventname created -action $action -sourceidentifier execreated; 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -