Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STDIN

Status
Not open for further replies.

court33

Programmer
Apr 9, 2002
2
0
0
US
I am writing a VBScript to create partitions on a W2K server and have ran into a problem that I can't get past. Any help would be greatly appreciated.

Everything was going great until it was time to automate the formating of the new partitions. My problem is answering "y" to the question "PROCEED WITH FORMAT Y/N?"
I tried using "WshShell.sendkeys " as in the following example but the key strokes do not reach the command window.

set WshShell = Wscript.CreateObject("WScript.Shell")
WshShell.Run"format d: /FS:NTFS /Q /V:",9
WshShell.sendkeys "y"
WshShell.sendkeys "{ENTER}"

I also tried reading the character "y" from an input file. This worked in the Batch File version but not in VBScript.

WshShell.Run(&quot;format e: /FS:NTFS /Q /V: <c:\entcss_disk_part\ans.txt&quot;),7, true


 
Try adding %Comspec% /c to the run method before the command you are trying to execute:

WshShell.Run(&quot;%Comspec% /c format e: /FS:NTFS /Q /V: <c:\entcss_disk_part\ans.txt&quot;),7, true

Regards,

Stein Borge
Author of: Managing Enterprise Systems with the Windows Script Host
Over 800 pages of practical solutions oriented material, providing
detailed coverage of WSH 5.6, ADSI, WMI, ADO, CDO, FSO and much more.
sb@nyetspam.enterprisewsh.com <- remove nyetspam when E-mailing
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top