Re: supress cmd line warnings from vbscript !! by ekkehard
ekkehard
Tue Jun 13 14:07:36 CDT 2006
maverick1611 wrote:
> hey Jim,
> i get an error saying "the system could not find the file specified" if
> I add "echo y | " to runattribcmd within the vbscript ..
> however if i run the "echo y | attrib -r c:\LogsFolder /S /D" command
> on command line it works perfectly
> any idea why ?
> thanks again
>
>
You need a shell to use echo (same as for device rerouting, by the
way):
Dim aTests : aTests = Array( _
"echo ThisWontWork" _
, "%comspec% /c echo ThisWillWork" _
)
Dim oShell : Set oShell = WScript.CreateObject( "WScript.Shell" )
Dim sCmd, vRet
For Each sCmd In aTests
WScript.Echo "sCmd: " + sCmd
On Error Resume Next
vRet = oShell.Run( sCmd, SW_SHOWMINNOACTIVE, True )
If 0 <> Err.Number Then
WScript.Echo "ERR: " & Err.Number & " - " & Err.Description
End If
On Error GoTo 0
WScript.Echo "vRet: " & vRet
WScript.Echo "------------------------------"
Next
> Jim wrote:
>
>>thry this line:
>>
>>runattribcmd = "echo y | attrib -r " + LogsFolder + " /S /D"
>>
>>
>>
>>
>>"maverick1611" <atulpandey@gmail.com> wrote in message
>>news:1150209069.941377.320410@f6g2000cwb.googlegroups.com...
>>
>>>Hi,
>>>I have a vbscript that runs an attrib comand to change the readonly
>>>property of a folder as follows
>>>
>>>runattribcmd = "attrib -r " + LogsFolder + " /S /D"
>>>dim wsh
>>>Set wsh = CreateObject("WScript.Shell")
>>>wsh.run runattribcmd, 7, false
>>>
>>>
>>>now my problem is that when this vbscript is run i get a popup command
>>>line window with "Are you sure?" on it and I have click "y" to continue
>>>..
>>>is there a way i can suppress this popup window. i always want to
>>>answer y for the warning .
>>>how do i do this ..
>>>thanks,
>>>mav
>>>
>
>