Solved

Extract vbscript code out of vbscript framework

Posted on 2013-11-21
2
429 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 250 total points
ID: 39665539
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
ID: 39665835
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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