Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run a Command Prompt cmd in a vb script.

Status
Not open for further replies.

BobSakemano

Technical User
Feb 17, 2005
20
0
0
NL
Guys, what’s the easiest way to access a directory and then running a command script.

Baiscly:

Cd [path]
Run Cmd

Should I use WSH? How would I go about doing it.
 
BobSakemano,

It is this.
Code:
pathspec="d:\abc\efg"    'your [path]
cmdline="xyz.exe"    'your Cmd

set wshshell=createobject("wscript.shell")
wshshell.currentdirectory=pathspec
wshshell.run cmdline
set wshshell=nothing
regards - tsuji
 
thanks but I get an error. This is my code:

pathspec="C:\Program Files\HP OpenView\Installed Packages\{790C06B4-844E-11D2-972B-080009EF8C2A}\bin"
cmdline="opcmsg appl=ScheduledTask obj=login severity=normal msg_text="hello""

set wshshell=createobject("wscript.shell")
wshshell.currentdirectory=pathspec
wshshell.run cmdline
set wshshell=nothing
 
>cmdline="opcmsg appl=ScheduledTask obj=login severity=normal msg_text="hello""

should be this (escaping quote so-to-speak by doubling it up)
[tt]
cmdline="opcmsg appl=ScheduledTask obj=login severity=normal msg_text=[red]""[/red]hello[red]""[/red]"
[/tt]
- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top