473,794 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using WSH scripts in vb.net

Folks,

Not sure if this is the correct forum for this posting, but I'm banging by
head against the wall, I have been trying to use my WSH scripts in vb. net
environment but not having much joy. The script is to create a shared folder
and set permission. I have added all referneces to WSH and WMI refernce in
VS2005. Can anyone tell me what changes do I need to make to the below code
to work in VB.NET? or even direct me to code for creating remote shares and
set permission in vb.net, I'm amazed at how diffcult it is to get vb.net code
to do such a simple thing!!! This code works fine in VBA environment such
Access that I'm currently running in.

Set WshNetwork = CreateObject("W Script.Network" )
Set objFS = CreateObject("S cripting.FileSy stemObject")

' creating the folder on a remote machine

Set objWMIService = GetObject _
("winmgmts:\ \" & strServerName & "\root\cimv2:Wi n32_Process")
errReturn = objWMIService.C reate _
("cmd.exe /cmd " & strFullPath & "", Null, Null, intProcessID)
' setting the sharing of a folder

Const FILE_SHARE = 0
Const MAXIMUM_CONNECT IONS = 25

Set objWMIService = GetObject _
("winmgmts:\ \" & strServerName & "\root\cimv 2")

Set objNewShare = objWMIService.G et("Win32_Share ")
strShareName = strGCN & "$"
errReturn = objNewShare.Cre ate("" & strFullPath & "", "" & strShareName &
"", FILE_SHARE, MAXIMUM_CONNECT IONS, "X Drive")

Call WshShell.Run("c acls " & USER_ROOT_UNC & " /e /g CS SysAdmin:F",
HIDE_WINDOW, WAIT_ON_RETURN)
Call WshShell.Run("c acls " & USER_ROOT_UNC & " /e /g " & strUser & ":C",
HIDE_WINDOW, WAIT_ON_RETURN)


Aug 20 '07 #1
3 5541
On Mon, 20 Aug 2007 04:34:08 -0700, Liam Mac
<Li*****@discus sions.microsoft .comwrote:
>Folks,

Not sure if this is the correct forum for this posting, but I'm banging by
head against the wall, I have been trying to use my WSH scripts in vb. net
environment but not having much joy. The script is to create a shared folder
and set permission. I have added all referneces to WSH and WMI refernce in
VS2005. Can anyone tell me what changes do I need to make to the below code
to work in VB.NET? or even direct me to code for creating remote shares and
set permission in vb.net, I'm amazed at how diffcult it is to get vb.net code
to do such a simple thing!!! This code works fine in VBA environment such
Access that I'm currently running in.

Set WshNetwork = CreateObject("W Script.Network" )
Set objFS = CreateObject("S cripting.FileSy stemObject")

' creating the folder on a remote machine

Set objWMIService = GetObject _
("winmgmts:\ \" & strServerName & "\root\cimv2:Wi n32_Process")
errReturn = objWMIService.C reate _
("cmd.exe /cmd " & strFullPath & "", Null, Null, intProcessID)
' setting the sharing of a folder

Const FILE_SHARE = 0
Const MAXIMUM_CONNECT IONS = 25

Set objWMIService = GetObject _
("winmgmts:\ \" & strServerName & "\root\cimv 2")

Set objNewShare = objWMIService.G et("Win32_Share ")
strShareName = strGCN & "$"
errReturn = objNewShare.Cre ate("" & strFullPath & "", "" & strShareName &
"", FILE_SHARE, MAXIMUM_CONNECT IONS, "X Drive")

Call WshShell.Run("c acls " & USER_ROOT_UNC & " /e /g CS SysAdmin:F",
HIDE_WINDOW, WAIT_ON_RETURN)
Call WshShell.Run("c acls " & USER_ROOT_UNC & " /e /g " & strUser & ":C",
HIDE_WINDOW, WAIT_ON_RETURN)

Personally I would use windows scripting host as a last resort,
because almost all anti viruses will block it right from the start.
What anti virus do you use?

--
http://bytes.thinkersroom.com
Aug 20 '07 #2
Hi
We have Mcafee anti-virus, but it doesn't seem to have a problem...

"Rad [Visual C# MVP]" wrote:
On Mon, 20 Aug 2007 04:34:08 -0700, Liam Mac
<Li*****@discus sions.microsoft .comwrote:
Folks,

Not sure if this is the correct forum for this posting, but I'm banging by
head against the wall, I have been trying to use my WSH scripts in vb. net
environment but not having much joy. The script is to create a shared folder
and set permission. I have added all referneces to WSH and WMI refernce in
VS2005. Can anyone tell me what changes do I need to make to the below code
to work in VB.NET? or even direct me to code for creating remote shares and
set permission in vb.net, I'm amazed at how diffcult it is to get vb.net code
to do such a simple thing!!! This code works fine in VBA environment such
Access that I'm currently running in.

Set WshNetwork = CreateObject("W Script.Network" )
Set objFS = CreateObject("S cripting.FileSy stemObject")

' creating the folder on a remote machine

Set objWMIService = GetObject _
("winmgmts:\ \" & strServerName & "\root\cimv2:Wi n32_Process")
errReturn = objWMIService.C reate _
("cmd.exe /cmd " & strFullPath & "", Null, Null, intProcessID)
' setting the sharing of a folder

Const FILE_SHARE = 0
Const MAXIMUM_CONNECT IONS = 25

Set objWMIService = GetObject _
("winmgmts:\ \" & strServerName & "\root\cimv 2")

Set objNewShare = objWMIService.G et("Win32_Share ")
strShareName = strGCN & "$"
errReturn = objNewShare.Cre ate("" & strFullPath & "", "" & strShareName &
"", FILE_SHARE, MAXIMUM_CONNECT IONS, "X Drive")

Call WshShell.Run("c acls " & USER_ROOT_UNC & " /e /g CS SysAdmin:F",
HIDE_WINDOW, WAIT_ON_RETURN)
Call WshShell.Run("c acls " & USER_ROOT_UNC & " /e /g " & strUser & ":C",
HIDE_WINDOW, WAIT_ON_RETURN)

Personally I would use windows scripting host as a last resort,
because almost all anti viruses will block it right from the start.
What anti virus do you use?

--
http://bytes.thinkersroom.com
Aug 22 '07 #3


"Rad [Visual C# MVP]" wrote:
On Mon, 20 Aug 2007 04:34:08 -0700, Liam Mac
<Li*****@discus sions.microsoft .comwrote:
Folks,

Not sure if this is the correct forum for this posting, but I'm banging by
head against the wall, I have been trying to use my WSH scripts in vb. net
environment but not having much joy. The script is to create a shared folder
and set permission. I have added all referneces to WSH and WMI refernce in
VS2005. Can anyone tell me what changes do I need to make to the below code
to work in VB.NET? or even direct me to code for creating remote shares and
set permission in vb.net, I'm amazed at how diffcult it is to get vb.net code
to do such a simple thing!!! This code works fine in VBA environment such
Access that I'm currently running in.

Set WshNetwork = CreateObject("W Script.Network" )
Set objFS = CreateObject("S cripting.FileSy stemObject")

' creating the folder on a remote machine

Set objWMIService = GetObject _
("winmgmts:\ \" & strServerName & "\root\cimv2:Wi n32_Process")
errReturn = objWMIService.C reate _
("cmd.exe /cmd " & strFullPath & "", Null, Null, intProcessID)
' setting the sharing of a folder

Const FILE_SHARE = 0
Const MAXIMUM_CONNECT IONS = 25

Set objWMIService = GetObject _
("winmgmts:\ \" & strServerName & "\root\cimv 2")

Set objNewShare = objWMIService.G et("Win32_Share ")
strShareName = strGCN & "$"
errReturn = objNewShare.Cre ate("" & strFullPath & "", "" & strShareName &
"", FILE_SHARE, MAXIMUM_CONNECT IONS, "X Drive")

Call WshShell.Run("c acls " & USER_ROOT_UNC & " /e /g CS SysAdmin:F",
HIDE_WINDOW, WAIT_ON_RETURN)
Call WshShell.Run("c acls " & USER_ROOT_UNC & " /e /g " & strUser & ":C",
HIDE_WINDOW, WAIT_ON_RETURN)

Personally I would use windows scripting host as a last resort,
because almost all anti viruses will block it right from the start.
What anti virus do you use?

--
http://bytes.thinkersroom.com
Aug 22 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1420
by: Adam | last post by:
I have an application which interacts with a webserver over https using client certificates. Due to a bug in openssl 0.9.6, I upgraded to 0.9.7 and rebuilt python. Now, when I access the page python is crashing with with a "bus error" and coring. Any insite as to what I need to do to fix this? The gdb output is below.
9
3658
by: Jeff Wagner | last post by:
I have a project of converting numerous DOS cmd shell scripts to Python. Is there a tutorial to getting started? Thanks, Jeff
13
9651
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
2
13350
by: volantecho | last post by:
hi, i m using webmin to create a cron job of a php script. While i click on 'run it now', it works, generate the output. However, the php script doesnt execute for every minutes which i've set to. besides the php scripts, i have other scripts run under cron jobs, such as perl scripts and log files. I couldnt understand why my php scripts doesnt work under cron job.
8
3995
by: doomx | last post by:
I'm using SQL scripts to create and alter tables in my DB I want to know if it's possible to fill the description(like in the Create table UI) using these scripts. EX: CREATE TABLE( Pk_myPrimaryKey INTEGER CONSTRAINT pk PRIMARY KEY DESCRIPTION 'This is the primary key of the table',
1
5571
by: fred_mumble | last post by:
I have been testing various techniques to run "script" code which will be stored in a SQL database and executed dynamically at runtime. The scripts are essentially business rules that result in a report being generated based on test parameters input by a user - 4 batches of scripts containing multiple functions will be run each time a user runs a new test. The reason the scripts are run in 4 batches is due to the fact that each batch is...
8
1993
by: Flip | last post by:
I have a website that's using Master pages (very cool). But when I put JS on there (to close the browser for example) coming from an external file, when I navigate away from the first page, the JS no longer works. Can someone explain why this is happening? How can I fix this so that the JS is generic enough to work on every aspx to be included in the external JS file? The external JS file looks like this right now function...
8
1665
by: Milsnips | last post by:
hi there, i'm currently using the following line: <script language="javascript" type="text/javascript" src="../scripts/timer.js"></script> but i want to do the following, as the script needs to be used in many pages at varios folder depths ( it is placed in my master page).
21
34440
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
2
37648
by: raghutumma | last post by:
Hi, How can we execute SQL Scripts using Batch file??? i think Batch file should contain Username,Password,Database and Scripts... Using that file scripts should run... How can i give UserName,Password,Database and all those things?
0
10433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10161
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9035
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6777
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.