VBScript to create Folder (Help)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • usafshah
    New Member
    • Nov 2006
    • 104

    #1

    VBScript to create Folder (Help)

    Hi Guys I'm new to VSscripts, I want to make a script which make a folder on current logged-in user's Desktop

    What I had tried is:
    ------------------------------------------------------------------------
    Dim objNet,objFSO, objFolder, strDirectory,te st

    On Error Resume Next


    Set objNet = CreateObject("W Script.NetWork" )

    Set objNet = CreateObject("W Script.NetWork" )
    If Err.Number <> 0 Then 'If error occured then display notice
    MsgBox "Don't be Shy." & vbCRLF &_
    "Do not press ""No"" If your browser warns you."
    Document.Locati on = "UserInfo.h tml"
    'Place the Name of the document.
    'It will display again
    End if



    Dim strInfo

    strInfo = objNet.UserName & vbCRLF




    strDirectory = "C:\Documen ts and Settings\" & strInfo & "Desktop\Da ta"


    Set objFSO = CreateObject("S cripting.FileSy stemObject")

    Set objFolder = objFSO.CreateFo lder(strDirecto ry)



    Set objNet = Nothing 'Destroy the Object to free the Memory
    -----------------------------------------------------------------------------------------------

    The Bold Line has problem but dont know whats that, Kaz i tried on other folders(without strInfo) and it worked
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by usafshah
    Hi Guys I'm new to VSscripts, I want to make a script which make a folder on current logged-in user's Desktop

    What I had tried is:
    ------------------------------------------------------------------------
    Dim objNet,objFSO, objFolder, strDirectory,te st

    On Error Resume Next


    Set objNet = CreateObject("W Script.NetWork" )

    Set objNet = CreateObject("W Script.NetWork" )
    If Err.Number <> 0 Then 'If error occured then display notice
    MsgBox "Don't be Shy." & vbCRLF &_
    "Do not press ""No"" If your browser warns you."
    Document.Locati on = "UserInfo.h tml"
    'Place the Name of the document.
    'It will display again
    End if



    Dim strInfo

    strInfo = objNet.UserName & vbCRLF




    strDirectory = "C:\Documen ts and Settings\" & strInfo & "Desktop\Da ta"


    Set objFSO = CreateObject("S cripting.FileSy stemObject")

    Set objFolder = objFSO.CreateFo lder(strDirecto ry)



    Set objNet = Nothing 'Destroy the Object to free the Memory
    -----------------------------------------------------------------------------------------------

    The Bold Line has problem but dont know whats that, Kaz i tried on other folders(without strInfo) and it worked
    Hi. Maybe it will work better without the newline character
    strInfo = objNet.UserName & vbCRLF

    like this
    strInfo = objNet.UserName

    Comment

    • usafshah
      New Member
      • Nov 2006
      • 104

      #3
      yeah it worked .. thanks for the support ;)

      Comment

      Working...