Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - open a file, wait for user to amend file, close & process

Reply
 
Old 07-29-2009   #1 (permalink)
snomad


 
 

open a file, wait for user to amend file, close & process

Hi all,

I'm creating a 'run ad hoc' sql file. It runs file.sql against a list of
servers. I want the user to be able to amend the contents of file.sql before
running it.

I need to get my script to open the file:
( notepad file.sql )
let the user amend & save the contents. then carry on & run the file.
( osql . . . -i file.sql )

I can get it to open file.sql but the rest of the script just plays on in
the background. It doesn't wait until the file is changed and closed.

If you help, I will be eternally grateful!







My System SpecsSystem Spec
Old 07-29-2009   #2 (permalink)
Robert Robelo


 
 

Re: open a file, wait for user to amend file, close & process

Pipe the notepad statement to Out-Null, this will cause the script to wait until notepad is closed by the user.

# create a test file
Set-Content qt.txt 'line 1'

# copy this script and run it
# -< script.ps1 >-
'start!'
notepad .\qt.txt | Out-Null
cmd /c type qt.txt
'done!'

--
Robert
My System SpecsSystem Spec
Old 07-29-2009   #3 (permalink)
snomad


 
 

Re: open a file, wait for user to amend file, close & process

Rob, you rock! This works like a dream. Thank you for taking the time to
answer.

"Robert Robelo" wrote:
Quote:

> Pipe the notepad statement to Out-Null, this will cause the script to wait until notepad is closed by the user.
>
> # create a test file
> Set-Content qt.txt 'line 1'
>
> # copy this script and run it
> # -< script.ps1 >-
> 'start!'
> notepad .\qt.txt | Out-Null
> cmd /c type qt.txt
> 'done!'
>
> --
> Robert
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Solved File menu open/close issue General Discussion
Failover Guest Cluster -- 'The process cannot access the file becauseit is being used by another process.' Virtual Server
in vb.net how to open a file from file download prompt without askinguser to save it or run it....just open it in internet explorer .NET General
Encrypt File / Decrypt File / Open/Close PSD Vista General
How to close open file handles? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46