WinBatch® Technical Support Forum

Archived Boards => COM Automation and dotNet => Topic started by: seckner on October 29, 2014, 02:01:37 PM

Title: Trying to use oShell.Run vs. oShell.Exec
Post by: seckner on October 29, 2014, 02:01:37 PM
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!
Title: Re: Trying to use oShell.Run vs. oShell.Exec
Post by: ....IFICantBYTE on October 29, 2014, 07:03:31 PM
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.
Title: Re: Trying to use oShell.Run vs. oShell.Exec
Post by: seckner on October 30, 2014, 04:37:42 AM
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!
Title: Re: Trying to use oShell.Run vs. oShell.Exec
Post by: td on October 30, 2014, 06:38:08 AM
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.