Solved

Extract vbscript code out of vbscript framework

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

636 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