473,406 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Running a EXE with parameters from script

17
I am trying to run a exe with parameters from a VB script. I tried writing it using a bat file but it does not close the dos prompt window so I am trying to rewrite it using VB script. It works if I do not specify any parameters for the exe to run. But i need it to run with the parameters. Not sure how to get it to run with the parameters. I need it to execute the exe then close the script. Here is my script.



Expand|Select|Wrap|Line Numbers
  1. strComputer = "."
  2. Set objWMIService = GetObject("winmgmts:" _
  3.     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  4. Set wshShell = WScript.CreateObject ("WSCript.shell")
  5. wshshell.run """c:\Program Files\UltraVNC\vncviewer.exe -dsmplugin MSRC4Plugin.dsm -listen 5900"""
Feb 7 '08 #1
9 35482
Killer42
8,435 Expert 8TB
I have a couple of questions. I'm only familiar with VB6, not VB Script, so I apologise if the questions don't make any sense...
  • Does c:\Program Files\UltraVNC\vncviewer.exe -dsmplugin MSRC4Plugin.dsm -listen 5900 work if you enter it yourself at the command prompt? And in the same location where your script will be issuing it?
  • Are you certain the string needs to include the extra double-quote characters? In other words, which of the should you be issuing...
    c:\Program Files\UltraVNC\vncviewer.exe -dsmplugin MSRC4Plugin.dsm -listen 5900
    or...
    "c:\Program Files\UltraVNC\vncviewer.exe -dsmplugin MSRC4Plugin.dsm -listen 5900"
Feb 8 '08 #2
Robbie
180 100+
This is based purely on my experience with shortcuts in Windows, but I think this is wrong...
"c:\path\file.exe -parameters"
...and this is right:
"c:\path\file.exe" -parameters

In other words, when you're setting that string, you need to do something like this:
chr(34)& "c:\path\file.exe" & chr(34) & " -parameters"
(Character 34's the speech-mark).

EDIT: In other words, the quotes should only be around the program, and the parameters come afterwords by themselves, out of quotes.
Feb 8 '08 #3
blazted
17
Thanks for the input. i figured it out by seprating the exe from the parameters.

Expand|Select|Wrap|Line Numbers
  1. wshshell.run """c:\Program Files\UltraVNC\vncviewer.exe"" -dsmplugin MSRC4Plugin.dsm -listen 5900"
A good littl tidbit i wont forget
Feb 8 '08 #4
Robbie
180 100+
Thanks for the input. i figured it out by seprating the exe from the parameters.

Expand|Select|Wrap|Line Numbers
  1. wshshell.run """c:\Program Files\UltraVNC\vncviewer.exe"" -dsmplugin MSRC4Plugin.dsm -listen 5900"
A good littl tidbit i wont forget
Heh, glad it helped. By the way, if you need to pass a single parameter with spaces, enclose that in speech-marks too. Otherwise they'll go through as separate ones, separated by the spaces. For example, if you want to make Notepad open a file in c:\the correct folder, you'd make the string for the shell to run be this:


"%SystemRoot%\system32\notepad.exe" "c:\the correct folder\file.txt"
Feb 8 '08 #5
blazted
17
Thanks for the input. i figured it out by seprating the exe from the parameters.

Expand|Select|Wrap|Line Numbers
  1. wshshell.run """c:\Program Files\UltraVNC\vncviewer.exe"" -dsmplugin MSRC4Plugin.dsm -listen 5900"
A good littl tidbit i wont forget
Actually I spoke to soon. For some reason it does not activate both command parameters only the last one. So it will activate the listen mode but it is not loading the plugin. I cannot get it to activate both listen mode and the plugin.

I first did this as a bat file but the bat file keeps the cmd window open until i turn off listen mode. Here is my bat file.
Expand|Select|Wrap|Line Numbers
  1. @echo on
  2. c:
  3. cd\
  4. cls
  5. cd "c:\Program Files\UltraVNC"
  6. call vncviewer.exe -dsmplugin MSRC4Plugin.dsm -listen 5900
  7. end
  8. exit
Any insight on getting both parameters to run? or if you even getting the bat file to run without keeping the cmp prompt window open.
Feb 8 '08 #6
blazted
17
I verified that I can get each parameter to run separately by trying to run the command with only one parameter as the argument.

Expand|Select|Wrap|Line Numbers
  1. wshshell.run """c:\Program Files\UltraVNC\vncviewer.exe"" -dsmplugin MSRC4Plugin.dsm"
This activated the viewer with the plug-in

Expand|Select|Wrap|Line Numbers
  1. wshshell.run """c:\Program Files\UltraVNC\vncviewer.exe""  "-listen 5900"
This activated the viewer. But when both parameters in the same quote it only will run the last parameter bypassing the first one.

I tried to separate each parameter with its own quotes but the script will not compile

Expand|Select|Wrap|Line Numbers
  1. wshshell.run """c:\Program Files\UltraVNC\vncviewer.exe"" -dsmplugin MSRC4Plugin.dsm" "-listen 5900"
Maybe this is simply a case of me forgetting a quote somewhere.
Feb 8 '08 #7
blazted
17
Any one have any more suggestions on this?
Feb 11 '08 #8
Killer42
8,435 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. wshshell.run """c:\Program Files\UltraVNC\vncviewer.exe"" -dsmplugin MSRC4Plugin.dsm" "-listen 5900"
Maybe this is simply a case of me forgetting a quote somewhere.
I don't know any more about the real issue, but you are definitely missing quotes here. Try this...
Expand|Select|Wrap|Line Numbers
  1. wshshell.run """c:\Program Files\UltraVNC\vncviewer.exe"" ""-dsmplugin MSRC4Plugin.dsm"" ""-listen 5900"""
Feb 12 '08 #9
thanks it helped alot
Oct 23 '17 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Will Seay | last post by:
At the end of this message I've pasted a script we're trying to modify slightly. I don't believe it is VBscript or javascript but these are the closest groups I could find with my limited...
9
by: Erik Geiger | last post by:
Hi, sorry, my english ist not that got but I'll try. I have a running python script (capisuit incoming.py). This script shall start a linux shell script. If I start this script like...
4
by: Stan Sainte-Rose | last post by:
Hi guys, I would like to run a vbs script from an asp page. I ve tried many directions but no one works.. The first was : Dim oShell Set oShell = Server.CreateObject("WSCript.shell")...
1
by: Bruce M | last post by:
Is there a way to run the db2-generated HADR-create script outside of DB2CC beyond the obvious? My DB2CC generates the HADR script and then abends because of a java error meaning I can't finish my...
10
by: shumaker | last post by:
I don't need a detailed description of a solution(although I wouldn't mind), but I am hoping someone could tell me in general the best path to go about accomplishing a task, since I don't know all...
5
by: merry.sailor | last post by:
Hello, I am using python and CGI to initiate a long running simulation (up to 5h long) on a remote machine. The main idea is that I use a form, enter the parameters and a CGI scripts start the...
8
by: Bernard Lebel | last post by:
Hello, I would like to know if there is a way to run a Python file under a different user account than the one logged in. Allow me to explain. There are a bunch of people here, they are "basic...
17
by: Csaba Gabor | last post by:
Is there a way to determine the path to the php executable (as opposed to the script. In other words, I am looking for the path to php.exe or php-win.exe) that is currently running (ie. how was...
14
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.