viewpoint-particle

Author Topic: Trying to use oShell.Run vs. oShell.Exec  (Read 2468 times)

seckner

  • Jr. Member
  • **
  • Posts: 66
Trying to use oShell.Run vs. oShell.Exec
« 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!

....IFICantBYTE

  • Full Member
  • ***
  • Posts: 119
Re: Trying to use oShell.Run vs. oShell.Exec
« Reply #1 on: October 29, 2014, 07:03:31 pm »
Try this:
Code: Winbatch
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

  • Jr. Member
  • **
  • Posts: 66
Re: Trying to use oShell.Run vs. oShell.Exec
« Reply #2 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!

td

  • Tech Support
  • *****
  • Posts: 2437
    • WinBatch
Re: Trying to use oShell.Run vs. oShell.Exec
« Reply #3 on: October 30, 2014, 06:38:08 am »
From the IPGraber Extender help file:

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

or

Code: Winbatch
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.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates