script to create Network shares?

Discussion in 'Software' started by dingoboy, Aug 6, 2004.

  1. dingoboy

    dingoboy Private E-2

    I need to create multiple network shares using variables I pull from a spreadsheet but when I use the userNom variable in the following script I get an Invalid parameter error 21. This script works if I replace userNom in line 7 with "Matt". Is there a way to do this with a variable?

    const FILE_SHARE=0
    Const MAXIMUM_CONNECTIONS=25
    strComputer="."
    userNom=Matt
    Set objWMIService=GetObject("winmgmts:"&"{impersonationLevel=impersonate}!\\"&strComputer&"\root\cimv2")
    Set objNewShare=objWMIService.Get("win32_Share")
    errReturn=objNewShare.Create("C:\"&userNom,userNom,FILE_SHARE,MAXIMUM_CONNECTIONS,"Share for"&UserNom)
    Wscript.Echo errReturn
    Thanks

     
  2. Kodo

    Kodo SNATCHSQUATCH

  3. Wookie

    Wookie Sergeant Major

    What type of variable is usernom? Thats not part of a class is it or something? Try making a string and setting it to matt then putting the string there, I dont know if usernom is something you created or not.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds