Solved

a script to create network place

Posted on 2007-11-22
14
474 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
ID: 20335169
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
ID: 20335330
0
 

Author Comment

by:jskfan
ID: 20335552
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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 12

Expert Comment

by:chandru_sol
ID: 20335559
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
ID: 20338734
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
ID: 20342567
any updates????
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20342737
0
 

Author Comment

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

Accepted Solution

by:
chandru_sol earned 500 total points
ID: 20343123
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
ID: 20343203
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
ID: 20343224
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
ID: 20343342
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
ID: 20343956
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
ID: 20386948
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Many people tend to confuse the function of a virus with the one of adware, this misunderstanding of the basic of what each software is and how it operates causes users and organizations to take the wrong security measures that would protect them ag…
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

803 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