Solved

a script to create network place

Posted on 2007-11-22
14
471 Views
Last Modified: 2012-08-14
when I use add my network places manually then when I get to Internet or Address Network, I enter this:
http://mysharepointserver:16701/sites/dmins/Administrators Library/ Administrator files
this will map a web folder to sharepoint server document library.

I wonder if there is a script that creates this network place , I need to put it in a logon script for windows XP users and Vista users.

Any help??

Thanks

0
Comment
Question by:jskfan
  • 7
  • 7
14 Comments
 
LVL 12

Expert Comment

by:chandru_sol
Comment Utility
I think we had discussed about this already here............

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_22968008.html

You want a differen solution
0
 
LVL 12

Expert Comment

by:chandru_sol
Comment Utility
0
 

Author Comment

by:jskfan
Comment Utility
on the previous post we talked about creating a shortcut to a folder inside Nethood. but I had to create the folder manually by going through add  Network place wizard.
what I need is the script that replaces the manual creation of a folder with network place wizard.

 
0
 
LVL 12

Expert Comment

by:chandru_sol
Comment Utility
Did you try the above link?

The folder which you are creating through the wizard is also shordut

regards
Chandru
0
 

Author Comment

by:jskfan
Comment Utility
on the previous post we managed to create a shortcut with a script that points to this location:
C:\Documents and Settings\username\NetHood
But  the web folder inside Nethood was created manually through Add Network Place.
if you add a network place manually through the wizard when you get to the step that says:
 Internet or Network Address:
you will enter this link: http://sharepointserver:16701/sites/Netadmins/Network Administrators Library/Network Administrator Files/

So what I need is the wizard to be run by the script and automatically enter http://sharepointserver:16701/sites/Netadmins/Network Administrators Library/Network Administrator Files/
I hope you understood my question.
0
 

Author Comment

by:jskfan
Comment Utility
any updates????
0
 
LVL 12

Expert Comment

by:chandru_sol
Comment Utility
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:jskfan
Comment Utility
which part of the script do I need to use?
0
 
LVL 12

Accepted Solution

by:
chandru_sol earned 500 total points
Comment Utility
The whole script is for your needs.

This is the help information in the script for the arguments required

'Displays help-text
Function HelpText()

MsgBox "Required parameters:" & vbNewLine & vbNewLine &_
" - /NAME ""<Resource name>""" & vbNewLine &_
" - /PATH ""<Path to resource>""" & vbNewLine & vbNewLine &_
"--- OR ---" & vbNewLine & vbNewLine &_
" - /DELETE" & vbNewLine &_
" - Deletes ALL resources in My network places (NETHOOD)" & vbNewLine &_
" - When using this command, script ignores /NAME and /PATH parameters, and will not create any new resource" & vbNewLine & vbNewLine &_
"Example:" & vbNewLine &_
strAppname & " /NAME ""Delade wordfiler"" /PATH ""\\sbab.ad\dfs\DeladeWordfiler""" & vbNewLine &_
strAppname & " /DELETE" & vbNewLine &_
"", vbInformation, strAppname & " - Required parameters"


Can you just copy the script and save as vbs file and it will let you know the options to create the required folders?

regards
Chandru
0
 

Author Comment

by:jskfan
Comment Utility
I am not sure what it does. I pasted it in a vbs format file and run it it gave me some errors related to the code you pasted above:
MsgBox "Required parameters:" & vbNewLine & vbNewLine &_
" - /NAME ""<Resource name>""" & vbNewLine &_
" - /PATH ""<Path to resource>""" & vbNewLine & vbNewLine &_
"--- OR ---" & vbNewLine & vbNewLine &_
" - /DELETE" & vbNewLine &_


I put an apostrophy at the left side of the lines that have error and rerun the script, but I am not sure what it has done.
0
 
LVL 12

Expert Comment

by:chandru_sol
Comment Utility
Try this script..........

Save the script as EditResource_1.0.vbs

run this to create the folder ---- EditResource_1.0.vbs /name "Foldername" /path "\\server\share"
'************************************************************************* 

'* File: EditResource_1.0.vbs 

'* Description: Creates or Deletes resources in "My network places" using input parameters 

'* For more info, run the file without paramers 

'* A failed run creates ERROR-events in Eventviewer 

'* 

'* Requirements: WSH 5.5 or higher. 

'* Created date: 2005-10-18 

'* 

'* Last modified: XXXX-XX-XX 

'* Last modfied by: <name> 

'* Information: .... 

'* 

'************************************************************************* 

Option Explicit 

Dim strPath, strName, strAppname, strNetHood, blnDeleteMode, objFSO, objWSHShell, objShell, objFolder, objFolderItem, blnVerboseMode 
 

'Set version and name of script (should be the same as script-name) 

strAppname = "EditResource_1.0.vbs" 

Const NETHOOD = &H13& 
 

'Create objects 

Set objFSO = CreateObject("Scripting.FileSystemObject") 

Set objWSHShell = CreateObject("Wscript.Shell") 

Set objShell = CreateObject("Shell.Application") 
 

'Set vars 

strPath = "" 

strName = "" 

blnDeleteMode = false 

Set objFolder = objShell.Namespace(NETHOOD) 

Set objFolderItem = objFolder.Self 
 

'Set this VAR to true to get MsgBox Errors instead of eventvwr-errors 

blnVerboseMode = false 
 
 

'Get inputs 

Call GetParams() 
 

'Create resource OR Delete all resource depending on parameter-input /DELETE 

If blnDeleteMode = True then 

Call EraseResources() 

Else 

Call CreateResource() 

End If 
 

'Clean up 

Set objShell = Nothing 

Set objFSO = Nothing 

Set objWSHShell = Nothing 

Set objFolder = Nothing 

Set objFolderItem = Nothing 
 

'Creates a resource in nethood 

Sub CreateResource() 
 

'Set vars to create resource 

strNetHood = objFolderItem.Path 
 

'Create resource 

Dim objShortcut, objDesktopIni, objNewLinkFolder, strIniFileContent 
 

'Don't create shortcut if an existing folder is already is named the same way 

If NOT objFSO.FolderExists(strNetHood & "\" & strName) AND objFSO.FolderExists(strNetHood) then 
 

'Create the main folder 

Set objNewLinkFolder = objFSO.CreateFolder(strNetHood & "\" & strName) 
 

'Create a desktop.ini below that folder 

Set objDesktopIni = objFSO.CreateTextFile(strNetHood & "\" & strName & "\Desktop.ini") 
 

'Set the content of Desktop.ini 

strIniFileContent = "[.ShellClassInfo]" & vbNewLine &_ 

"CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}" & vbNewLine &_ 

"Flags=2" & vbNewLine &_ 

"ConfirmFileOp=1" 
 

'Write content to INI-file 

objDesktopIni.Write strIniFileContent 

objDesktopIni.Close 
 

'Reopen Desktop.ini as file-object to set attribs 

Set objDesktopIni = objFSO.GetFile(strNetHood & "\" & strName & "\Desktop.ini") 
 

'Create target.lnk (used to point where the system-folder-path shall be) 

Set objShortcut = objWSHShell.CreateShortcut (strNetHood & "\" & strName & "\target.lnk") 

objShortcut.TargetPath = strPath 

objShortcut.IconLocation = "%SystemRoot%\system32\SHELL32.DLL, 85" 

objShortcut.Description = strPath 

objShortcut.WorkingDirectory = strPath 
 

'Save shortcut to NETHOOD 

On Error Resume Next 

objShortcut.Save 
 

'After everything is created - Set required Attribs on the folders / files 

objDesktopIni.Attributes = 6 'Hidden and System 

objNewLinkFolder.Attributes = 1 'Read only 
 

'Clean up 

Set objShortcut = nothing 

Set objNewLinkFolder = nothing 

Set objDesktopIni = nothing 
 

'If Error - Create an eventlog containing the error 

If Err.Number <> 0 then 

objWSHShell.LogEvent 1, strAppname & " error:" & vbNewLine & "Cannot create resource:" & strPath & vbNewLine & "Error detail:" & Err.Description 

End If 
 

End If 

End Sub 
 

'Empties all the resources from nethood 

Sub EraseResources() 
 

Dim oFolder, oSubFolders, oCurrentSubFolder 
 

'Remove all links created as files 

strPath = objFolderItem.Path & "\*.*" 

On Error Resume Next 

objFSO.DeleteFile strPath, true 
 

'If Error - Create an eventlog containing the error 

If Err.Number <> 0 then 

objWSHShell.LogEvent 1, strAppname & " error:" & vbNewLine & "Cannot empty folder of files:" & strPath & vbNewLine & "Error detail:" & Err.Description 

End If 
 

'Some shortcuts are folders, loop and delete all of them too 

Set oFolder = objFSO.GetFolder(objFolderItem.Path) 

Set oSubFolders= oFolder.SubFolders 
 

For Each oCurrentSubFolder in oSubFolders 

On Error Resume Next 

objFSO.DeleteFolder oCurrentSubFolder, true 
 

'If Error - Create an eventlog containing the error 

If Err.Number <> 0 then 

objWSHShell.LogEvent 1, strAppname & " error:" & vbNewLine & "Cannot empty folder of subfolders:" & strPath & vbNewLine & "Error detail:" & Err.Description 

End If 

Next 
 
 

End Sub 
 

'Get's parameters supplied, and checks if valid 

Sub GetParams() 
 

Dim objArgs 

Set objArgs = WScript.Arguments 
 

If objArgs.Count = 0 Then 

Call HelpText() 

Wscript.Quit(0) 

Else 
 

Dim i, intArgCount, strTempParse, intRequiredParameters, currentArg, errMessage 
 

'Count number of args passed to script 

intArgCount = objArgs.Count - 1 
 

'Set how many args that are required, decrease this value with 1 each time a required value is valid and set 

intRequiredParameters = 2 
 

For i = 0 to intArgCount 

currentArg = objArgs(i) 
 

If Ucase(currentArg) = "/PATH" then 
 

'Control that the value for this parameter exists 

If intArgCount >= i + 1 then 
 

'Control that it is valid 

If objFSO.FolderExists(objArgs(i + 1)) then 
 

'Get the value of the valid parameter 

strPath = objArgs(i + 1) 
 

'Mark that 1 required parameter is set 

intRequiredParameters = intRequiredParameters - 1 
 

Else 

errMessage = GetParamsBuildError(currentArg, errMessage, " - Folder does not exist or no access to it: " & objArgs(i + 1)) 

End If 
 

Else 

errMessage = GetParamsBuildError(currentArg, errMessage, " - No value for parameter") 

End If 
 

ElseIf Ucase(currentArg) = "/NAME" then 
 

'Control that the value for this parameter exists 

If intArgCount >= i + 1 then 
 

'Control that it is valid 

If len(objArgs(i + 1)) > 0 then 
 

'Get the value of the valid parameter 

strName = objArgs(i + 1) 
 

'Mark that 1 required parameter is set 

intRequiredParameters = intRequiredParameters - 1 
 

Else 

errMessage = GetParamsBuildError(currentArg, errMessage, " - No name specified") 

End If 
 

Else 

errMessage = GetParamsBuildError(currentArg, errMessage, " - No value for parameter") 

End If 
 

ElseIf Ucase(currentArg) = "/DELETE" then 
 

'Set deletemode, and ignore the rest of the parameters 

blnDeleteMode = true 
 

errMessage = "" 

intRequiredParameters = 0 

Exit For 
 

End If 
 

Next 
 
 
 

'If any error or missing parameters display error to user 

If len(errMessage) > 0 OR NOT intRequiredParameters = 0 then 
 

If NOT intRequiredParameters = 0 then 

errMessage = GetParamsBuildError("", errMessage, vbNewLine & " - Not all required parameters specified or valid") 

End If 
 

If blnVerboseMode = true then 
 

'Create a Messagebox containing the error 

Dim intSeeHelp 

intSeeHelp = MsgBox("Parameter Errors:" & vbNewLine & errMessage & vbNewline & vbNewline & "Do you want to see the help?", 308, "Error in parameters") 
 

If intSeeHelp = 6 then 

HelpText() 

End If 
 

Else 

'Create an eventlog containing the error 

objWSHShell.LogEvent 1, strAppname & " error:" & vbNewLine & errMessage 

End If 
 

'Quit with error-code -1 

Wscript.Quit(-1) 
 

End If 

End If 
 

End Sub 
 
 
 

'Displays help-text 

Function HelpText() 
 

MsgBox "Required parameters:" & vbNewLine & vbNewLine &_ 

" - /NAME ""<Resource name>""" & vbNewLine &_ 

" - /PATH ""<Path to resource>""" & vbNewLine & vbNewLine &_ 

"--- OR ---" & vbNewLine & vbNewLine &_ 

" - /DELETE" & vbNewLine &_ 

" - Deletes ALL resources in My network places (NETHOOD)" & vbNewLine &_ 

" - When using this command, script ignores /NAME and /PATH parameters, and will not create any new resource" & vbNewLine & vbNewLine &_ 

"Example:" & vbNewLine &_ 

strAppname & " /NAME ""Delade wordfiler"" /PATH ""\\sbab.ad\dfs\DeladeWordfiler""" & vbNewLine &_ 

strAppname & " /DELETE" & vbNewLine &_ 

"", vbInformation, strAppname & " - Required parameters" 
 

End Function 
 
 
 

'Builds errorstring when parsing parameters 

Function GetParamsBuildError(strArgument, errMessage, strErrortxt) 

GetParamsBuildError = errMessage &_ 

Ucase(strArgument) &_ 

strErrortxt &_ 

vbNewLine 

End Function 

Open in new window

0
 

Author Comment

by:jskfan
Comment Utility
It does the same thing as the previous one.

 I put an apostrophy at the left side of the lines that have error and rerun the script, but I am not sure what it has done.
0
 

Author Comment

by:jskfan
Comment Utility
The script should create a folder type web folder.
this folder will be inside Web Folders, it will have as target URL:
http://sharepointserver:16701/sites/Netadmins/Network Administrators Library/Network Administrator files
0
 
LVL 12

Expert Comment

by:chandru_sol
Comment Utility
How do you create this using the add/remote network wizard so that i can try here and see how the folder is created?

regards
Chandru
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now