Solved

Extract vbscript code out of vbscript framework

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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