?
Solved

Start a program via VBScript

Posted on 2011-05-04
11
Medium Priority
?
593 Views
Last Modified: 2012-06-27
I'm looking for some advice regarding a VBScript that I have.

Here's the deal:The last two lines of my Vbscript launches a program and passes it a parameter.
And it works great.

And here's what the lines looks  like:Set objApp = CreateObject("WScript.Shell")
objApp.Run "cmd /c CD C:\ & ""Program Files\Maze Computer\Manifest Maker\sxs32cmd.exe"" C:\Manifest.sxs32mm"

My problem is:It seems if I add any lines AFTER, obj.App.Run, the application program (Program Files\Maze Computer\Manifest Maker\sxs32cmd.exe ) tells me it’s not being passed the parameter C:\Manifest.sxs32mm.

I have tried enclosing C:\Manifest.sxs32mm in double quotes but, it didn’t have a positive effect.

Right now, in order to get the job done,  I have three VBScripts.

A parent script,  which calls Child1.Vbs waits 15 seconds and then calls Child2.Vbs.
Child1.Vbs is the script that ends by launching the above application and passes it a parameter.
Child2.Vbs, does “the rest” of the things I need to do after the application, launched by Child1.Vbs has completed.

My goal, is to combine Child1 and Child 2 into the same VBScript.
But, I can't quite figure out why I can’t seem to add lines to the end of the existing Child1.Vbs script.

Any advice would be greatly appreciated.

Thanks in advance.
0
Comment
11 Comments
 
LVL 6

Expert Comment

by:cfEngineers
ID: 35691373
give us the code so we can take a crack at it.
0
 
LVL 14

Accepted Solution

by:
BigBadWolf_000 earned 2000 total points
ID: 35691589
Try this instead...
StrManifestPath = "C:\Program Files\Maze Computer\Manifest Maker"
strParamDB = chr(34) & "C:\Manifest.sxs32mm" & chr(34)
Set objShell = CreateObject("WScript.Shell")
objShell.Run chr(34) & StrManifestPath & "\sxs32cmd.exe" & chr(34) & strParamDB, 1, "False"
Set objShell = Nothing

Open in new window

0
 
LVL 1
ID: 35691857
Thanks for the suggestion.

Nothing happens when I run the above.
I bring up task manager to "whatch" things, and the executable is not being lauched at all.

Any other ideas are more than welcome.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 59

Expert Comment

by:Bill Prew
ID: 35691938
In the earlier post, I do notice a missing space between the program name and the parms.  Maybe something like this:

objShell.Run chr(34) & StrManifestPath & "\sxs32cmd.exe" & chr(34) & " " & strParamDB, 1, "False"

~bp
0
 
LVL 1
ID: 35692027
Thank you for that.
All suggestions are appreciated.

Unfortunatly, I haven't suceeded yet.
In that,  the application (sxs32cmd.exe) doesn't get lauched. (I'm watching the task manager)

Here's what the code currently looks like.StrManifestPath = "C:\Program Files\Maze Computer\Manifest Maker)"
strParamDB = chr(34) & "C:\Manifest.sxs32mm" & chr(34)
Set objShell = CreateObject("WScript.Shell")
'objShell.Run chr(34) & StrManifestPath & "\sxs32cmd.exe" & chr(34) & strParamDB, 1, "True"
objShell.Run chr(34) & StrManifestPath & "\sxs32cmd.exe" & chr(34) & " " & strParamDB, 1, "False"
Set objShell = Nothing
0
 
LVL 14

Expert Comment

by:BigBadWolf_000
ID: 35692460
first line there should be no closed paranthesis at end of line
rkode: I am assuming your program "sxs32cmd.exe" opens file "Manifest.sxs32mm"

The initial code posted is ok no space required
Copy and pate my initial code to notepad, save file as test.vbs, launch it post results ans any errors
Which OS and version are you using
0
 
LVL 1
ID: 35692547
Thanks.

Will do.
0
 
LVL 1
ID: 35697481
Hello again BBW, et al

Sorry for the delay, but my boss asked me to look into another issue yesterday.

I can confirm that IF, I copy your code, exactly as you posted it, into notepad and save it with a Vbs extension, it does indeed start my executable and pass the parameter to it.

But
When I place lines of code in front ofyour code, then,  the application fails to launch.
Nothing.
No messages.
No dos box.
Nothing.

The lines of code that I place in front of your code, are the lines,  that create the file,  that is used by the executable.
It is the file that is passed to the executable. (C:\Manifest.sxs32mm).

I'm now beginng to wonder if perhaps the newly created file is not available to the application for some reason.
Which is why your code dosen;t seem to run if combined with my lines of code.
But DOES work, if run as a seperate .Vbs script.
Hmmmmmmmm.

I'm going to begin anew (in about 30 minutes or so) to work on this.

I'll update this forum with my progress.

Thanks once again to you as well as everyone else, for your time and efforts on my behalf.

I truly DO appreciate them.

More to come .........
0
 
LVL 14

Expert Comment

by:BigBadWolf_000
ID: 35699137
If you can post your entire code then I may be able to help you resolve faster.
:)
0
 
LVL 1
ID: 35699362
I now have things working. (Thanks to you)

The primary "fix" was to use your code.
StrManifestPath = "C:\Program Files\Maze Computer\Manifest Maker"
strParamDB = chr(34) & "C:\Manifest.sxs32mm" & chr(34)
Set objShell = CreateObject("WScript.Shell")
objShell.Run chr(34) & StrManifestPath & "\sxs32cmd.exe" & chr(34) & strParamDB, 1, "False"
Set objShell = Nothing

Now that I see your code, it makes perfect sense.

As usual, I managed to shoot myself in the foot when testing yesterday afternoon.
My script WAS failing to work properly.
But,  it was of my own device.
And nothing at all to do with your code suggestion.

As it turns out, my boss asking me to look into some else yesterday afternoon, turns out to be a good thing. (For this issue.)

Cuz, this morning, with a fresh perspective (and coffee). I was able to make things work in pretty short order.

Thanks once again for your time, efforts and of course your code, while I was putting things together.

I truly DO appreciate this.







0
 
LVL 1

Author Closing Comment

by:Accidental Hyper-V Administrator
ID: 35699372
Perfect !
Exactly what I needed.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question