+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 27
Scripts Thread, New to scripting in Coding and Web Development; Hello I am new to scripting, I have never done it before and I don’t know much about it. Please ...
  1. #1

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,383
    Thank Post
    797
    Thanked 1,585 Times in 1,388 Posts
    Blog Entries
    10
    Rep Power
    427

    New to scripting

    Hello

    I am new to scripting, I have never done it before and I don’t know much about it. Please can people give me pointers and tech me how to make a script to map network drives & one to setup printers on computers.

    Thanks A lot

  2. #2

    Join Date
    Mar 2007
    Posts
    1,669
    Thank Post
    72
    Thanked 249 Times in 199 Posts
    Rep Power
    64

    Re: New to scripting

    http://www.ss64.com/nt/con2prt.html
    just stick an environment variable on each machine(can also be scripted) then it allows you to choose printers based on machine, you can also create a different script for groups, so admin get a different list to students,

    net use z: /d

    net use p: \\servername\public

    should cover your mapped drives.

    http://www.microsoft.com/technet/scr...qanda/all.mspx

    generic good site for scripts, needs a little twiddling, but shows u what can be done

  3. #3
    ChrisC's Avatar
    Join Date
    Mar 2006
    Location
    Dorset
    Posts
    767
    Thank Post
    2
    Thanked 1 Time in 1 Post
    Rep Power
    18

    Re: New to scripting

    to map network drives, usually a batch file will do it. so if you know the dos commands for mapping network drives, that's usually the easiest way.

    Create a text file (use notepad if you want) then save it as mapping.bat or something remember to save it as all files, otherwise it'll add the .txt extension on the end.

    here's an example map.bat script

    net use x: \\server\c$

    Simple as that for mapping drives (prolly an easier way someone else can come up with)

    vbs scripts etc get more complex.

    Theres many ways to script!

    Chris

  4. #4
    ChrisC's Avatar
    Join Date
    Mar 2006
    Location
    Dorset
    Posts
    767
    Thank Post
    2
    Thanked 1 Time in 1 Post
    Rep Power
    18

    Re: New to scripting

    gahhhhhhhhhhh beat me to it :P

    Chris

  5. #5

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,383
    Thank Post
    797
    Thanked 1,585 Times in 1,388 Posts
    Blog Entries
    10
    Rep Power
    427

    Re: New to scripting

    Right and how would i apply that to a user account is it the box under the user profile location in the user properties in AD, i cant remember its name sorry.

    Zak

  6. #6

    Join Date
    Mar 2007
    Posts
    1,669
    Thank Post
    72
    Thanked 249 Times in 199 Posts
    Rep Power
    64

    Re: New to scripting

    yup, you can assign logon scripts to indivudal users, or do it in batches ( ie select a few users).

    below is the vbs to set a variable on a machine.
    ------------------------------

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    Set objVariable = objWMIService.Get("Win32_Environment").SpawnInstan ce_

    objVariable.name = "ROOM"
    objVariable.UserName = "<system>"
    objVariable.VariableValue = "INEEDS"
    objVariable.Put_

    ----------------------
    room is the varibale name, in INEEDS in this case is the variable.


    so to make it work.
    1. make logon script, save it to the netlogon file of your server.
    2. assign script to user
    3. assign variable to computer.
    4. sit back and enjoy!.

    below is a test script
    rEM Mapping printers via an enviromental variable
    \\servername\NETLOGON\CON2PRT /F

    IF %ROOM% == SENIORICT \\severname\netlogon\CON2PRT /CD \\Servername\lanierlp025

  7. #7

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,383
    Thank Post
    797
    Thanked 1,585 Times in 1,388 Posts
    Blog Entries
    10
    Rep Power
    427

    Re: New to scripting

    Quote Originally Posted by strawberry
    yup, you can assign logon scripts to indivudal users, or do it in batches ( ie select a few users).

    below is the vbs to set a variable on a machine.
    ------------------------------

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    Set objVariable = objWMIService.Get("Win32_Environment").SpawnInstan ce_

    objVariable.name = "ROOM"
    objVariable.UserName = "<system>"
    objVariable.VariableValue = "INEEDS"
    objVariable.Put_

    ----------------------
    room is the varibale name, in INEEDS in this case is the variable.


    so to make it work.
    1. make logon script, save it to the netlogon file of your server.
    2. assign script to user
    3. assign variable to computer.
    4. sit back and enjoy!.

    below is a test script
    rEM Mapping printers via an enviromental variable
    \\servername\NETLOGON\CON2PRT /F

    IF %ROOM% == SENIORICT \\severname\netlogon\CON2PRT /CD \\Servername\lanierlp025
    I might sound stupid but i dont understand.

  8. #8

    Join Date
    Mar 2007
    Posts
    1,669
    Thank Post
    72
    Thanked 249 Times in 199 Posts
    Rep Power
    64

    Re: New to scripting

    not sure i do either :P.

    bascially heres a list of things to do
    1. download cntprinter file thingy, place it as a folder into your netlogon share of your server. \\servername\netlogon.
    2.create a bat file, call it students.bat
    3. copy code into bat file
    ---
    rEM Mapping printers via an enviromental variable
    \\servername\NETLOGON\CON2PRT /F

    IF %ROOM% == SENIORICT \\severname\netlogon\CON2PRT /CD \\Servername\lanierlp025
    ---
    4.change servername\lanierlp025 to a name of a shared printer on your network, save to netlogon folder
    5.assign bat file to user as a logon script. ( as its in netlogon you can address just the file name eg NOT \\server\netlogon\students.bat but students.bat
    6.set an environment variable on your pc , call it room, and set value to SENIORICT.

    run script on your pc.

  9. #9

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,383
    Thank Post
    797
    Thanked 1,585 Times in 1,388 Posts
    Blog Entries
    10
    Rep Power
    427

    Re: New to scripting

    Right i think i get that.

    I havejust been having a go with the map network drives one, i put the following into a notepad

    net use X: \\FN-DC-02\Network Drives\Enterpsie
    net use Y: \\FN-DC-01\Network Drives\Shared Documents
    net use Z: \\ST0\Media
    I named it map.bat

    Put it in "netlogon"

    On the account properties i put map.bat on the logon script

    But it doesnt work, Why?

  10. #10

    Join Date
    Mar 2007
    Posts
    1,669
    Thank Post
    72
    Thanked 249 Times in 199 Posts
    Rep Power
    64

    Re: New to scripting

    try running it as a file on your computer, see if that works.

    i'd bet x is a spelling mistake, and i think y needs brackets as dos doens't like spaces in address's.

    net use Y: "\\FN-DC-01\Network Drives\Shared Documents"

    you'll also need to use "net use u: /d" to delete each mapped drive as u logon, so delete the drives, then add the new drives, even if theyre the same.

  11. #11

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,383
    Thank Post
    797
    Thanked 1,585 Times in 1,388 Posts
    Blog Entries
    10
    Rep Power
    427

    Re: New to scripting

    is was these little "marks" that did it (what are the names again). ok so would i put "net use u: /d" at the bottom on the script?

  12. #12

    Join Date
    Mar 2007
    Posts
    1,669
    Thank Post
    72
    Thanked 249 Times in 199 Posts
    Rep Power
    64

    Re: New to scripting

    put the delete (net use u: /d) first, then add the new drives. not sure why to be honest, the only use i can think of is when the system stands by and you need to run the logon script to refresh it when it wakes.

  13. #13

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,383
    Thank Post
    797
    Thanked 1,585 Times in 1,388 Posts
    Blog Entries
    10
    Rep Power
    427

    Re: New to scripting

    I bet your sick of me by now, I put the script as the following

    "net use u: /d"
    net use X: "\\FN-DC-02\Network Drives\Enterprise"
    net use Y: "\\FN-DC-01\Network Drives\Shared Documents"
    net use Z: "\\ST0\Media
    But it isn’t deleting existing Network Drives, were have i gone wrong?

    Thanks for your help

  14. #14

    Join Date
    Mar 2007
    Posts
    1,669
    Thank Post
    72
    Thanked 249 Times in 199 Posts
    Rep Power
    64

    Re: New to scripting

    quotes are only used to hide spaces in address from dos ( dos doens't like spaces).


    net use x: /d
    net use y: /d
    net use z: /d
    net use X: "\\FN-DC-02\Network Drives\Enterprise"
    net use Y: "\\FN-DC-01\Network Drives\Shared Documents"
    net use Z: \\ST0\Media

    and is my pleasure, this website got me through the first year in my job so i'm only to glad to be helping others!

  15. #15
    petectid's Avatar
    Join Date
    Jun 2005
    Posts
    298
    Thank Post
    2
    Thanked 15 Times in 13 Posts
    Rep Power
    19

    Re: New to scripting

    Visit this site http://www.microsoft.com/technet/scr...r/learnit.mspx

    Get hold of some books on scripting I used Windows Scripting self paced learning guide and Windows 2000 scripting guide both from MS Press. Both books come with a Cd that contain all the example scripts. A simple vbs script to map two network drives, does the same job as the net use commands in the above posts.

    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.MapNetworkDrive "P:" , "\\server\sharename"
    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.MapNetworkDrive "S:" , "\\server\sharename"

    As you will see more drives can be added when needed, and with a few more commands you could test for group membership and map drives that are dependent on which groups you are a member of.

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Scripting Resources
    By ChrisH in forum Scripts
    Replies: 20
    Last Post: 27th March 2012, 11:39 AM
  2. Delete a folder using scripting
    By FN-GM in forum Scripts
    Replies: 15
    Last Post: 22nd December 2007, 04:44 PM
  3. using the 'auto configuration Scripting' in IE
    By Liam in forum How do you do....it?
    Replies: 9
    Last Post: 25th October 2007, 01:34 PM
  4. ADMT and or Scripting ACL changes.
    By pete in forum Windows
    Replies: 4
    Last Post: 25th October 2006, 08:38 PM
  5. Scripting IP configuration.
    By Dos_Box in forum Scripts
    Replies: 3
    Last Post: 2nd September 2005, 09:07 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •