Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Calling Executable from VBScript

Reply
 
Old 11-04-2008   #1 (permalink)
sweetsilver99


 
 

Calling Executable from VBScript

I wrote a script to gather information about the current user logged
into the computer. I need to get the computer SID, and have only had
accurate results from calling PSGetSID. How can I call PSGetSID with
out opening up a shell and write the output to a text file. Here is
my first try at this, which flashes up a empty shell, (contains only
part of the code of the entire script):

Set objShell = CreateObject("WScript.Shell")
strCommand = localpath & "H:\psgetsid.exe " & strComputer
Set objExecObject = objShell.Exec(strCommand)
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadAll()
loop
objTextFile.WriteLine("Computer SID: " & VbTab & VbTab & strText)
objTextFile.Close

My System SpecsSystem Spec
Old 11-04-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: Calling Executable from VBScript


"sweetsilver99" <edvoroznak@xxxxxx> wrote in message
news:55f04b33-8fac-4950-914e-b2bb661b3e85@xxxxxx
Quote:

>I wrote a script to gather information about the current user logged
> into the computer. I need to get the computer SID, and have only had
> accurate results from calling PSGetSID. How can I call PSGetSID with
> out opening up a shell and write the output to a text file. Here is
> my first try at this, which flashes up a empty shell, (contains only
> part of the code of the entire script):
>
> Set objShell = CreateObject("WScript.Shell")
> strCommand = localpath & "H:\psgetsid.exe " & strComputer
> Set objExecObject = objShell.Exec(strCommand)
> Do While Not objExecObject.StdOut.AtEndOfStream
> strText = objExecObject.StdOut.ReadAll()
> loop
> objTextFile.WriteLine("Computer SID: " & VbTab & VbTab & strText)
> objTextFile.Close
Have a look at this example published by the Scripting Guy:
How Can I Modify the Output of the Ping Command -
http://www.microsoft.com/technet/scr...6/hey0817.mspx


My System SpecsSystem Spec
Old 11-04-2008   #3 (permalink)
sweetsilver99


 
 

Re: Calling Executable from VBScript

On Nov 4, 9:06*am, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "sweetsilver99" <edvoroz...@xxxxxx> wrote in message
>
> news:55f04b33-8fac-4950-914e-b2bb661b3e85@xxxxxx
>
Quote:

> >I wrote a script to gather information about the current user logged
> > into the computer. *I need to get the computer SID, and have only had
> > accurate results from calling PSGetSID. *How can I call PSGetSID with
> > out opening up a shell and write the output to a text file. *Here is
> > my first try at this, which flashes up a empty shell, (contains only
> > part of the code of the entire script):
>
Quote:

> > * * * * * * * *Set objShell = CreateObject("WScript.Shell")
> > strCommand = localpath & "H:\psgetsid.exe " & strComputer
> > Set objExecObject = objShell.Exec(strCommand)
> > Do While Not objExecObject.StdOut.AtEndOfStream
> > strText = objExecObject.StdOut.ReadAll()
> > loop
> > objTextFile.WriteLine("Computer SID: " & VbTab & VbTab & strText)
> > objTextFile.Close
>
> Have a look at this example published by the Scripting Guy:
> How Can I Modify the Output of the Ping Command -http://www.microsoft.com/technet/scriptcenter/resources/qanda/aug06/h...
That almost does what I want I just do not want a shell, empty or not,
to not pop open. I found this following information maybe this will
work:
http://publib.boulder.ibm.com/infoce...610uaref89.htm

Note: The "0" parameter in the following oshell.run commands is used
to hide the
' shell-created DOS command window. The "true" parameter means
to halt script
' execution until the called program finishes and returns
control.

rc = oshell.run("kumpping", 0, true)
if rc <> 0 then
wscript.echo "Status from kumpping is " & rc
wscript.echo "Verify that the Universal Agent API Data Provider is
active. Exiting..."
wscript.quit
end if

My System SpecsSystem Spec
Old 11-04-2008   #4 (permalink)
Richard Mueller [MVP]


 
 

Re: Calling Executable from VBScript


"sweetsilver99" <edvoroznak@xxxxxx> wrote in message
news:b61913b6-12b7-4cdb-81ba-0420ee805ce9@xxxxxx
On Nov 4, 9:06 am, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "sweetsilver99" <edvoroz...@xxxxxx> wrote in message
>
> news:55f04b33-8fac-4950-914e-b2bb661b3e85@xxxxxx
>
Quote:

> >I wrote a script to gather information about the current user logged
> > into the computer. I need to get the computer SID, and have only had
> > accurate results from calling PSGetSID. How can I call PSGetSID with
> > out opening up a shell and write the output to a text file. Here is
> > my first try at this, which flashes up a empty shell, (contains only
> > part of the code of the entire script):
>
Quote:

> > Set objShell = CreateObject("WScript.Shell")
> > strCommand = localpath & "H:\psgetsid.exe " & strComputer
> > Set objExecObject = objShell.Exec(strCommand)
> > Do While Not objExecObject.StdOut.AtEndOfStream
> > strText = objExecObject.StdOut.ReadAll()
> > loop
> > objTextFile.WriteLine("Computer SID: " & VbTab & VbTab & strText)
> > objTextFile.Close
>
> Have a look at this example published by the Scripting Guy:
> How Can I Modify the Output of the Ping
> Command -http://www.microsoft.com/technet/scriptcenter/resources/qanda/aug06/h...
That almost does what I want I just do not want a shell, empty or not,
to not pop open. I found this following information maybe this will
work:
http://publib.boulder.ibm.com/infoce...610uaref89.htm

Note: The "0" parameter in the following oshell.run commands is used
to hide the
' shell-created DOS command window. The "true" parameter means
to halt script
' execution until the called program finishes and returns
control.

rc = oshell.run("kumpping", 0, true)
if rc <> 0 then
wscript.echo "Status from kumpping is " & rc
wscript.echo "Verify that the Universal Agent API Data Provider is
active. Exiting..."
wscript.quit
end if


The Run method accepts up to 3 parameters, only the first is required. If
the second parameter is 0 the app runs hidden. 1 means normal (default), 2
minimized, 3 maximized. There seems to be nothing similar for the Exec
command.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Calling a VBScript from Access VB Script
calling WinAPIs from VBScript VB Script
Running an executable within a VBscript VB Script
Vbscript calling DTS package VB Script
Error handling when calling external executable PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46