Solved

Extract vbscript code out of vbscript framework

Posted on 2013-11-21
2
419 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

914 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

12 Experts available now in Live!

Get 1:1 Help Now