cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DaveinJP
Engaged Sweeper III
I have shares occasionally created by software that I would like to manage and remove using a software deployment. I have the deployment process running right and have used it to update lansweeper itself now with success. Admittedly, I'm having trouble wrapping my brain around the syntax of the script. Can anyone give me a basic example of how to add and remove shares?

thank you in advance,
Dave
1 ACCEPTED SOLUTION
Bert_D
Lansweeper Employee
Lansweeper Employee
It seems i totally misinterpreted your intension there.

What i would do is, create a package with a 'Command' step.
Paste the command I would normally use in a command prompt in this step.
(ex. net share YOUR_SHARE_NAME /delete)

After that, deploy the package to a selection of assets.

Our 'Command' step is basically a command that is executed in the command prompt on the targeted asset.

Happy New Year

View solution in original post

5 REPLIES 5
syarbrough
Engaged Sweeper
Old thread, but subject is pretty much what we are doing..

Any idea why using deplay, with COMMAND step, and the command
net use z: /delete

doesnt appear to be working?
The command works if we manually go to the computer and run it in a prompt, the deploy flashes a command box for a second as its firing, we arent seeing anything taking affect.
Last time we used deploy its was prior to the update to v. 7.0.110.2... Was wondering if there is something we need to change in our config to keep the deploy working?

Thanks
DaveinJP
Engaged Sweeper III
Straightforward and simple. Thank you very much.
Bert_D
Lansweeper Employee
Lansweeper Employee
It seems i totally misinterpreted your intension there.

What i would do is, create a package with a 'Command' step.
Paste the command I would normally use in a command prompt in this step.
(ex. net share YOUR_SHARE_NAME /delete)

After that, deploy the package to a selection of assets.

Our 'Command' step is basically a command that is executed in the command prompt on the targeted asset.

Happy New Year
DaveinJP
Engaged Sweeper III
Thanks so much for the reply. This is great, but not quite what I was looking for.

I'll use the lansweeper installer as an example:

It creates a lansweeper$ share and a defaultpackageshare$ upon install. On 30 or so servers that only have the scanning component of Lansweeper, these shares are not necessary.

I would like to create a package and deploy it to remove these shares from those systems rather than manually do it.

In a normal command prompt, I can simply issue the "net share lansweeper$ /delete" command to remove the share.

thank you again,
Dave
Bert_D
Lansweeper Employee
Lansweeper Employee
Simple vbs script to first map a drive and then unmap it again
Dim objNetwork
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "I:", "PATH_OF_SHARE","True","jdoe","jdoepassword"
objNetwork.RemoveNetworkDrive "I:"


Slightly more advanced vbs script mapping a drive without a drive letter and then unmapping it again if exists


Dim objNetwork
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "", "PATH_OF_SHARE","True","jdoe","jdoepassword"

Set objDrives = objNetwork.EnumNetworkDrives
If objDrives.Count > 0 Then
For i = 0 To objDrives.Count-1 Step 2
If objDrives.Item(i+1) = "PATH_OF_SHARE" Then
objNetwork.RemoveNetworkDrive "PATH_OF_SHARE", True, True
i=objDrives.Count-1
End If
Next
End If


Hope this helps you on your way