Welcome to ServerForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Wshell.Exec

 
   Windows Server (Home) -> Windows Server Scripting RSS
Next:  Exchange or Outlook Question  
Author Message
drwjr




Joined: Mar 09, 2007
Posts: 1



(Msg. 1) Posted: Fri Mar 09, 2007 2:46 pm
Post subject: Wshell.Exec

I use Winbatch to do my Windows scripting. Tech support at Wilson Windowware provided me with a user-defined function because I couldn't get two of their built-in functions (RunShell and ShellExecute) to run correctly while accepting parameters. The code for the user-defined function is below:

#DefineFunction GetSTDOUT(cmd)
objShell = ObjectOpen("WScript.Shell")
objWshScriptExec = objShell.Exec(cmd)
objStdOut = objWshScriptExec.StdOut
line = objStdOut.ReadAll
objStdOut = 0
objWshScriptExec = 0
objShell = 0
Return line
#EndFunction

Now, to use this function to run a DOS command-line utility, I simply define the cmd variable (such as cmd = "ipconfig /all"). And this user-defined function has worked perfectly for every command-line utility that I've thrown at it.......except one. If I run "wmic SERVICES LIST BRIEF" manually, from the command line, it runs just fine and displays a list of installed services (for those that are going to suggest it, I don't like the output of the sc command).

But if I set the value of the cmd variable to that (cmd = "wmic SERVICES LIST BRIEF") and run my script, to run that user-defined function, I get an Ole Exception Error (the error dialog box say, "Error: C:\Program Files\Winbatch\System\SMTPConnect.wbt 1261: Ole: Exception ON line 51 of C:\Program...h\System\SMTPConnect.wbt In Routine "getstdout" objWshScriptExec = objShell.Exec(cmd) ").

I contacted the person that created the above user-defined function but she said that she didn't know enough about Wscript to figure out why trying to have it run wmic would cause this Ole exception error.

Does anyone know why this won't work and what I can do to get it working?

 >> Stay informed about: Wshell.Exec 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Scheduled VBScript can't launch network program via wShell.. - I have a Windows 2003 member server in a W2k Domain. I also have other Windows 2003 servers that don't have the problem I'm about to describe, but this one does. I've narrowed the problem down to basics. I now have a very simple script that..

exec.vbs - I'm working with 2000 Resource Kit delivered WMI remote scripting process exec.vbs. I'm starting to tweak it because it doesn't quite do what I want. My biggest issue: It doesn't return an error code if a remote process failed to start properly. ..

WshShell.Exec - Hi group ! I need some help with a startup script handled using GPO. It doesn't execute the external program. If I run it as login script at user level everything is fine but teh user need to be local admin in roder to install software. Have you got....

'objWshShell.Exec - Can someone please tell me whats wrong with this line of code? Set objShellExecSet = objWshShell.Exec("cmd.exe /c set|find /i " & Chr(34) & "SystemDrive" & Chr(34)) I'm getting the following error when running it from a ...

shell.exec vs cmd line? - Howcome this works from the command line (w2k3): dsquery user -samid %username% -o dn | dsget user -memberof but running it in a script like this fails: set oUserDN = oShell.exec("dsquery user -samid %username% -o dn | dsget user -memberof")...
   Windows Server (Home) -> Windows Server Scripting All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]