Login | |
|
 |
RE: objShell.Run vs objShell.Exec - 5/17/2006 4:52:51 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
Why can't you use .Run? " I'm scanning a subnet that has 254 addresses it does this very very fast!" What do you mean by scanning? Could you post your code?
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: objShell.Run vs objShell.Exec - 5/17/2006 4:53:30 AM
|
|
 |
|
| |
Country73
Posts: 716
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
|
Add this to the beginning of your code: If Instr(1, WScript.FullName, "CScript", vbTextCompare) = 0 Then oShell.Run "cscript """ & WScript.ScriptFullName & """", 0, False WScript.Quit End If Change to 0 to a 1 if you want the CMD Window visible
|
|
| |
|
|
|
 |
RE: objShell.Run vs objShell.Exec - 5/17/2006 4:57:29 AM
|
|
 |
|
| |
mcds99
Posts: 429
Score: 4
Joined: 2/28/2006
Status: offline
|
If I run it as a cscript (why didn't I think of that before I posted) Problem not solved within the script. or can I call an external script from within a script and have it run in cscript? Would be nice to make this work without changeing the default script type... Would this be possible to do if I wrapped it with an HTA program? hmmmm... A batch file would work but... yuck Any Ideas would be wonderful! TIA
_____________________________
Sam Keep it Simple Make it Fun KiSMiF
|
|
| |
|
|
|
 |
RE: objShell.Run vs objShell.Exec - 5/17/2006 11:34:26 PM
|
|
 |
|
| |
Country73
Posts: 716
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
|
So you're telling me that what I posted DOES NOT hide the command window when using objShell.Exec?
|
|
| |
|
|
|
 |
RE: objShell.Run vs objShell.Exec - 5/18/2006 3:10:07 AM
|
|
 |
|
| |
mcds99
Posts: 429
Score: 4
Joined: 2/28/2006
Status: offline
|
I used a wrapper ;-) first I created a file "file.cmd" in this file is "cscript script.vbs" Then I created a shortcut and ran it minimized it works
_____________________________
Sam Keep it Simple Make it Fun KiSMiF
|
|
| |
|
|
|
 |
RE: objShell.Run vs objShell.Exec - 5/22/2006 12:35:25 AM
|
|
 |
|
| |
Country73
Posts: 716
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
|
???
|
|
| |
|
|
|
 |
RE: objShell.Run vs objShell.Exec - 5/23/2006 2:17:32 AM
|
|
 |
|
| |
mcds99
Posts: 429
Score: 4
Joined: 2/28/2006
Status: offline
|
To hide the command prompt windows (stop them from flashing) I used a "wrapper". Insted of running the script using wscript I use cscript. To do this you need to create a text file myfile.bat or myfile.cmd I use .cmd as the filename extension because it runs in 32bit mode. That, and we have W2K3 64 bit and XP 64 bit machines (btw XP64 is the bomb!) Most vbscripts will run at the command line "cscript" just fine so the line in the file "cscript myscript.vbs" runs in 1 command prompt window (no flashing) I use an Shortcut to supress the 1 command prompt window by running it minimized. The myfile.cmd is wrapped around the myscript.vbs, or myscript.vbs runs from myfile.cmd
_____________________________
Sam Keep it Simple Make it Fun KiSMiF
|
|
| |
|
|
|
 |
RE: objShell.Run vs objShell.Exec - 5/23/2006 8:59:54 AM
|
|
 |
|
| |
Country73
Posts: 716
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
|
That's fine; if you want to go through all of that, or you can just put those four lines that I posted, into your script and it forces it to run in cscript with no CMD window. Whichever is your preference.
|
|
| |
|
|
|
 |
RE: objShell.Run vs objShell.Exec - 8/24/2007 2:15:11 AM
|
|
 |
|
| |
jpook
Posts: 30
Score: 0
Joined: 3/7/2007
Status: offline
|
I'm new & you say put this at the start of the code? ========================================================================= If Instr(1, WScript.FullName, "CScript", vbTextCompare) = 0 Then oShell.Run "cscript """ & WScript.ScriptFullName & """", 0, False WScript.Quit End If ========================================================================= How would that work with this... Not looking for you to do it for me, but can you point me in the right direction. ========================================================================= Dim objNetwork : Set objNetwork = CreateObject("WScript.Network") Dim localIP : localIP = ResolveIP(objNetwork.ComputerName) ' <span class="high">Get</span> local ip by calling function below Dim arrIPOct : arrIPOct = Split(localIP, ".") ' create an array out of the IP Select Case arrIPOct(2) ' look at the value for the network x.x.X.x Case "105" WScript.Echo "location 1: x..105.x" Case "107" WScript.Echo "location 2: x.x.107.x" Case "106" WScript.Echo "location 3: x.x.106.x" Case "104" WScript.Echo "location 4: x.x.104.x" End Select Function ResolveIP(computerName) Dim objShell : Set objShell = CreateObject("WScript.Shell") Dim objExec : Set objExec = objShell.Exec("ping " & computerName & " -n 1") Dim RegEx : Set RegEx = New RegExp RegEx.Pattern = "\[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]" RegEx.IgnoreCase = True RegEx.Global = True ResolveIP = RegEx.Execute(objExec.StdOut.ReadAll)(0).Submatches(0) End Function ========================================================================
|
|
| |
|
|
|
 |
RE: objShell.Run vs objShell.Exec - 8/27/2007 6:54:03 AM
|
|
 |
|
| |
mcds99
Posts: 429
Score: 4
Joined: 2/28/2006
Status: offline
|
ObjShell.Run does not do standard output like ObjShell.Exec. If you want output you need to use ObjShell.Exec
_____________________________
Sam Keep it Simple Make it Fun KiSMiF
|
|
| |
|
|
|
 |
RE: objShell.Run vs objShell.Exec - 8/28/2007 7:52:36 AM
|
|
 |
|
| |
mcds99
Posts: 429
Score: 4
Joined: 2/28/2006
Status: offline
|
I've had odd results from the wmiPing, I think the script runs so fast it doesn't give the wmiping time to finish. The regular ping takes a long time, I like the wmiPings speed. +'s and -'s in everything.
_____________________________
Sam Keep it Simple Make it Fun KiSMiF
|
|
| |
|
|
|
|
|