I have a script that works perfect for mapping a drive X: to a share that is always created. I want to use %computername% but it won't accept it. My goal is to have a logon script and I am mapping back to the local computer. So I want to create a share %computername%\%temp% and then map x: to that share. Here is what I have so far that works if I hard code a windows box name in. I need help getting the code for the creation of the share as well.
Code:'========================================================================== ' NAME: NetworkMap.vbs ' ' AUTHOR: Jason Poth ' DATE : 1/27/2012 ' ' COMMENT: ' This script maps X drive to "\\Server\Share" and then launch Program '========================================================================== Dim objFSO, objNetwork, WshShell Set WshShell = WScript.CreateObject("WScript.Shell") set objFSO = CreateObject("Scripting.FileSystemObject") Set objNetwork = CreateObject("WScript.Network") '----------------------------------------------------------------- 'If the "x" drive is already mapped, disconnect the mapping If (objFSO.DriveExists("x:")) Then objNetwork.RemoveNetworkDrive "x:", True, True End If '----------------------------------------------------------------- objNetwork.MapNetworkDrive "x:" , "\\win7dev\temp" If Err.Number<>0 Then MsgBox "Error in mapping drive!!!!" MsgBox "Error #" & Err.Number & " " & Err.Description End If '----------------------------------------------------------------- 'Execute Program '----------------------------------------------------------------- WshShell.Run "P:\program.exe%" If Err.Number<>0 Then MsgBox "Unable to launch program !" MsgBox "Error #" & Err.Number & " " & Err.Source & " " & Err.Description End If set WshShell = Nothing




Reply With Quote