Trying to use oShell.Run vs. oShell.Exec

Started by seckner, October 29, 2014, 02:01:37 PM

Previous topic - Next topic

seckner

Using the oShell.Run Method instead of the oShell.Exec -  run allows .Run(strCommand, [intWindowStyle], [bWaitOnReturn])

SO here's what I'm trying to do:

objShell = ObjectOpen("WScript.Shell")
objWshScriptExec = objShell.Run("cmd /C ipconfig | clip.exe")
oShell = 0

I get the output from ipconfig into the clipboard, where I want it. The big difference I'm trying to work out is using Run and I haven't figured out how to put the arguments in without it throwing an error. I want to set the second parameter to zero which hides the DOS window and set the third parameter to wait till it completes.

DOS straight to the clipboard, no DOS window. Then I can use ClipGet() to work with the output. I haven't figured out how to put the arguments in without it throwing an error. Any help GREATLY appreciated!

....IFICantBYTE

Try this:
Code (winbatch) Select
objShell = ObjectOpen("WScript.Shell")
objWshScriptExec = objShell.Run("cmd /C ipconfig | clip.exe" , 0, @TRUE)
;TimeDelay(1) ; Only needed if @TRUE (1) is not used on the objShell.Run wait on return argument. Otherwise, the clipboard contents will probably not be updated by clip.exe yet, and we get the previous contents.
objShell = 0
Message("",ClipGet())

Exit


This seems to work pretty well on my PC, but just in case it isn't suiting your purposes fully, you know that there are other ways of getting this IP info without using cmd windows, and there are also other methods of returning command window output too... there should be examples in the Tech Database.
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

seckner

Thank you!! Seriously. Right in front of my and I just couldn't see it. I'm writing a little utility to pull the arp -a %ip info% so we can grab the MAC address. This will help make the "flashing window" go away. Thank you!

td

From the IPGraber Extender help file:

Code (winbatch) Select

AddExtender("wwipg44i.dll")
maclist = ipMacAddrAllFmt()
AskItemList("ipMacAddrAllFmt", maclist, @tab, @unsorted, @single )


or

Code (winbatch) Select

AddExtender("wwipg44i.dll")
mac = ipMacAddrFirstFmt()
Message("ipMacAddrFirstFmt - mac address", mac)


Of course you can use the WIL ClipPut function place the results on the clipboard.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade