/build/static/layout/Breadcrumb_cap_w.png

running CMD in silent

anybody know a switch or have a VBScript that will run the cmd windows in silent without showing any black windows?. I have tried the /c , but as you know the window does pop up and exits when done, so there anyway i can stop it from poping up at all?.
thanks

0 Comments   [ + ] Show comments

Answers (11)

Posted by: selnomeria 11 years ago
White Belt
1

 here is a simple command to open cmd in silent mode with vbs:

 Set ws=CreateObject("WScript.Shell")
ws.Run "TASKKILL.exe /F /IM iexplore.exe"
Posted by: Tone 17 years ago
Second Degree Blue Belt
0
What is it you are trying to do?

you could run a vbscript using ccript.exe //b script.vbs or start /min cmd /c "dir *.*" would only show cmd windows on taskbar..
Posted by: bkelly 17 years ago
Red Belt
0
If your script does not generate any output, you might try running it with Wscript.exe instead of Cscript.exe. If you are not specifying the interpreter on the command line, you can set the default like so:

cscript //H:WScript

If there is output, each line appears in its own dialog box, so don't use this method unless there is no output currently echoing to the command prompt.
Posted by: Tone 17 years ago
Second Degree Blue Belt
0
Oops, I meant wscript.exe //b script.vbs

[8|]
Posted by: justinSingh 17 years ago
Blue Belt
0
my script is listed below and i'm calling it from within my msi as an embedded custom action, but every time it launches through the MSI it pops 3 cmd windows that run in minimized mode. I have also tried this script with the 0 and 7 , but the results are the same and the funny thing is that if i run the script alone without calling it through the MSI i get no cmd windows...just a clean silent install. Anyone have any ideas?


on error resume next

Dim Username
Dim Workstation
Dim WshShell
Dim filesys
DIM arrBinaryValues()
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const strComputer = "."
Const Reg_SZ = 1
Const Reg_Expand_SZ = 2
Const Reg_Binary = 3
const reg_DWORD = 4
Const Reg_Multi_SZ = 7
Const HKEY_Current_User = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("Wscript.Shell")
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&strComputer&"\root\default:StdRegProv")
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")


'Determine if Intel 2200 Network Exists

Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)

For each Item in colItems
If instr(Item.PNPDeviceID, "PCI\VEN_8086&DEV_4220") <> 0 Then 'If Card Exists

'Stop Wireless Service
wshShell.run "cmd /c net stop WZCSVC",0,True
'Save Network Settings

Set colItems = objWMIService.ExecQuery("SELECT Index FROM Win32_NetworkAdapter WHERE Name LIKE '%2200%'","WQL",wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
Pad = 4 - Len(objItem.Index)
strInterfaceNum = String(Pad, "0") & objItem.Index
Next

strKeyPath = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"&strInterfaceNum
strValueName = "NetCfgInstanceId"
oReg.GetStringValue HKEY_Local_Machine,strKeyPath,strValueName,strValue
strNetCfgInstance = strValue


If strNetCfgInstance <> "" Then
strKeyPath = "SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces\"&strNetCfgInstance
oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes
Set objMarker = objFSO.CreateTextFile("C:\temp\IntelWireless.txt", ForWriting)
For i=0 to UBound(arrValueNames)
If arrValueTypes(i) = REG_BINARY Then
strBinValue = ""
oReg.GetBinaryValue HKEY_Local_Machine,strKeyPath,arrValueNames(i),arrValue
For j=0 to UBOUND(arrValue)
strByte = CStr(hex(arrValue(j)))
If Len(strByte) = 1 Then strByte = "0"&strByte
strBinValue = strBinValue & strByte
Next
ObjMarker.WriteLine "Intel2200BG,EAPOL,REG_BINARY,"&arrValueNames(i)&","&strBinValue

End IF
Next
End IF


If strNetCfgInstance <> "" Then
strKeyPath = "SOFTWARE\Microsoft\WZCSVC\Parameters\Interfaces\"&strNetCfgInstance
oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes
For i=0 to UBound(arrValueNames)
If arrValueNames(i) <> "ActiveSettings" or arrValueNames(i) <> "LayoutVersion" Then
If arrValueTypes(i) = REG_BINARY Then
strBinValue = ""
oReg.GetBinaryValue HKEY_Local_Machine,strKeyPath,arrValueNames(i),arrValue
For j=0 to UBOUND(arrValue)
strByte = CStr(hex(arrValue(j)))
If Len(strByte) = 1 Then strByte = "0"&strByte
strBinValue = strBinValue & strByte
Next
ObjMarker.WriteLine "Intel2200BG,WZCSVC,REG_BINARY,"&arrValueNames(i)&","&strBinValue
ElseIF arrValueTypes(i) = REG_DWORD Then
oReg.GetDWORDValue HKEY_LOCAL_MAchine,strKeyPath,arrValueNames(i),dwValue
ObjMarker.WriteLine "Intel2200BG,WZCSVC,REG_DWORD,"&arrValueNames(i)&","&dwValue
End If
End If
Next
End IF
objMarker.Close


'Run Driver Install
wshShell.run "cmd /C c:\drivers\nc6220\n\iprodifx.exe /silent",0,True

'Restore Network Setting
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&strComputer&"\root\default:StdRegProv")
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")


Set colItems = objWMIService.ExecQuery("SELECT Index FROM Win32_NetworkAdapter WHERE Name LIKE '%2200%'","WQL",wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
Pad = 4 - Len(objItem.Index)
strInterfaceNum = String(Pad, "0") & objItem.Index
Next


strKeyPath = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"&strInterfaceNum
strValueName = "NetCfgInstanceId"
oReg.GetStringValue HKEY_Local_Machine,strKeyPath,strValueName,strValue
strNetCfgInstance = strValue



set objMarker = objFSO.OpenTextFile("C:\temp\IntelWireless.txt", ForReading)

test = oReg.GetStringValue(HKEY_Local_Machine,"SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces\"&strNetCfgInstance,,strValue)
If test <> 0 Then
oReg.CreateKey HKEY_Local_Machine,"SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces\"&strNetCfgInstance
End If
Do Until objMarker.AtEndOfStream
strTest = objMarker.Readline
arrInfo = split(strTest,",")
Select Case arrInfo(1)
Case "EAPOL"
strKeyPath = "SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces\"&strNetCfgInstance
Case "WZCSVC"
strKeyPath = "SOFTWARE\Microsoft\WZCSVC\Parameters\Interfaces\"&strNetCfgInstance
End Select
SELECT CASE arrInfo(2)
CASE "REG_BINARY"
Redim arrBinaryValues((Len(arrInfo(4))))
x=-1
For i = 1 to Len(arrInfo(4)) step 2
x = x + 1
arrBinaryValues(x) = CByte("&H"&MID(arrInfo(4),i,2))
Next
Redim Preserve arrBinaryValues(x)
test = oReg.SetBinaryValue(HKEY_Local_Machine,strKeyPath,arrInfo(3),arrBinaryValues)
CASE "REG_DWORD"
test = oReg.SetDWORDValue(HKEY_Local_Machine,strKeyPath,arrInfo(3),arrInfo(4))


END SELECT
Loop
objMarker.close
'Enable Wireless Configuration Service
wshShell.run "cmd /c net stop WZCSVC",0,True








End If
Next



Set WshShell = nothing
Posted by: KrisBcn 17 years ago
Purple Belt
0
Hi!
Have you tried to run the command without the "cmd /c" ?
wshShell.run "net stop WZCSVC",0,True
then the ",0,true" is for silent execution, but I don't think you need the cmd...

KrisBcn
Posted by: bheers 17 years ago
Second Degree Blue Belt
0
I agree with krisbcn, you can just use the command and ignore the cmd.exe.
Posted by: jamsek19 17 years ago
Orange Senior Belt
0
Justin,
try this way.:

Function RunCmd(acmd, ByRef a_cmd_out)
Set ShellObj = CreateObject("WScript.Shell")
Set ExecObj = ShellObj.Exec(a_cmd)
If Err.number <> RTN_OK Then
RunCMD = Err.Number
Wscript.Echo "Running " & a_cmd & " failed."
Set ExecObj = Nothing
Set ShellObj = Nothing
Exit Function
End If
i = 0
Do While ExecObj.Status = 0
Wscript.Sleep 1
i = i + 1
Loop
If Err.Number = RTN_OK Then
RunCMD = ExecObj.ExitCode
Else
RunCMD = Err.Number
End If
a_cmd_out = ExecObj.StdOut.ReadAll
Set ExecObj = Nothing
Set ShellObj = Nothing
End Function



By VBScript 5.6 help:
This function runs an application in a child command-shell, providing access to the StdIn/StdOut/StdErr streams.
The Exec method returns a WshScriptExec object, which provides status and error information about a script run with Exec along with access to the StdIn, StdOut, and StdErr channels. The Exec method allows the execution of command line applications only. The Exec method cannot be used to run remote scripts. Do not confuse the Exec method with the Execute method (of the WshRemote object).


But sometimes this function returns me an error (I do not know why) therefore I need use your function on this way:

Function RunWindowedCMD(a_cmd)
winState = 7 ' Displays the window as a minimized window. The active window remains active.
' can be also 10 - Sets the show-state based on the state of the program that started the application.
Set ShellObj = CreateObject("WScript.Shell")
RunWindowedCMD = ShellObj.Run( a_cmd, winState, True)
Wscript.echo "CMD return " & RunWindowedCMD
Set ShellObj = Nothing
End Function


with winstate = 7 appears just minimized window in TaskBar.


Best regards
Andreo
Posted by: justinSingh 17 years ago
Blue Belt
0
hummm, stupid me ...
it seems that when i created my package and added the script afterwards, i never compiled my package . I was just using file->save and that caused my 3 cmd windows to pop up rather then running only in silent mode.
thanks for your help guys!
Posted by: bearden3 12 years ago
Purple Belt
0
Do you realize that what you are replying to is over 4 years old?
Posted by: kardock 12 years ago
Second Degree Green Belt
0
ORIGINAL: bearden3

Do you realize that what you are replying to is over 4 years old?



roflmao!
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ