Solved

Extract vbscript code out of vbscript framework

Posted on 2013-11-21
2
417 Views
Last Modified: 2013-11-25
Hi,

I'd need to extract some vbscripting code out of a vbscripting framework.
I'm new to vbscripting so please advise howto.

Goal is to use a "standalone" vbscript made of a part of the scripting framework.
It starts with subruncmd but don't know what code I need to put before this in my new/seperate script.

Example code: Code


Please advise.
J.
0
Comment
Question by:janhoedt
2 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 250 total points
Comment Utility
Your link contained
subRunCmd "Configure FW", "", "netsh advfirewall firewall set rule group=""Remote Desktop"" new enable=yes"

Open in new window


You are simply looking for a line of code that starts with either sub subRunCmd or function subRunCmd

sub subRunCmd variable1,v2,v3
   some code
   some code
   some code
end sub

Open in new window

0
 
LVL 6

Assisted Solution

by:Alan Gunn
Alan Gunn earned 250 total points
Comment Utility
Hi!
It looks from the example code that the VBscript is executing a command line.

I would guess that the first bit of info you send it "Configure FW", is used in a report log.

The command you are passing is
"netsh advfirewall firewall set rule group=""Remote Desktop"" new enable=yes"


NETSH is a comand that is used to set a large number of network related parameters.
The advfirewall context of Netsh is shown here
http://technet.microsoft.com/en-us/library/dd734783(v=ws.10).aspx

To execute a command line in VBscript you create a wscript.shell object which allows you to gain control of the command shell.
http://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.84).aspx

You then start a command processor and pass it the command line you want.

The only fiddly bit is making sure that parts of the comamnd line that need to be in quotes are passed properly.
To indicate to VBs that you want a quote inside a sting, you preceed it with another quote.

The other parameters used by the shell object are "Window type" and "Wait on completion"
In this example, the window is 0 for hidden and the wait for completion is true.

Hope this helps
@@
<
\__/

Cheers!

TRM

strCommand = "netsh advfirewall firewall set rule group=""Remote Desktop"" new enable=yes"

Set objShell = CreateObject("WScript.Shell")
objShell.Run "%comspec% /c " & strCommand , 0, True

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now