473,320 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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("WScript.Network")
Set objFS = CreateObject("Scripting.FileSystemObject")

' creating the folder on a remote machine

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

Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25

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

Set objNewShare = objWMIService.Get("Win32_Share")
strShareName = strGCN & "$"
errReturn = objNewShare.Create("" & strFullPath & "", "" & strShareName &
"", FILE_SHARE, MAXIMUM_CONNECTIONS, "X Drive")

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


Aug 20 '07 #1
3 5525
On Mon, 20 Aug 2007 04:34:08 -0700, Liam Mac
<Li*****@discussions.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("WScript.Network")
Set objFS = CreateObject("Scripting.FileSystemObject")

' creating the folder on a remote machine

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

Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25

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

Set objNewShare = objWMIService.Get("Win32_Share")
strShareName = strGCN & "$"
errReturn = objNewShare.Create("" & strFullPath & "", "" & strShareName &
"", FILE_SHARE, MAXIMUM_CONNECTIONS, "X Drive")

Call WshShell.Run("cacls " & USER_ROOT_UNC & " /e /g CS SysAdmin:F",
HIDE_WINDOW, WAIT_ON_RETURN)
Call WshShell.Run("cacls " & 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*****@discussions.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("WScript.Network")
Set objFS = CreateObject("Scripting.FileSystemObject")

' creating the folder on a remote machine

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

Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25

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

Set objNewShare = objWMIService.Get("Win32_Share")
strShareName = strGCN & "$"
errReturn = objNewShare.Create("" & strFullPath & "", "" & strShareName &
"", FILE_SHARE, MAXIMUM_CONNECTIONS, "X Drive")

Call WshShell.Run("cacls " & USER_ROOT_UNC & " /e /g CS SysAdmin:F",
HIDE_WINDOW, WAIT_ON_RETURN)
Call WshShell.Run("cacls " & 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*****@discussions.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("WScript.Network")
Set objFS = CreateObject("Scripting.FileSystemObject")

' creating the folder on a remote machine

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

Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25

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

Set objNewShare = objWMIService.Get("Win32_Share")
strShareName = strGCN & "$"
errReturn = objNewShare.Create("" & strFullPath & "", "" & strShareName &
"", FILE_SHARE, MAXIMUM_CONNECTIONS, "X Drive")

Call WshShell.Run("cacls " & USER_ROOT_UNC & " /e /g CS SysAdmin:F",
HIDE_WINDOW, WAIT_ON_RETURN)
Call WshShell.Run("cacls " & 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
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...
9
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
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...
2
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...
8
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(...
1
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...
8
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...
8
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...
21
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...
2
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.