【发布时间】:2021-01-10 06:32:47
【问题描述】:
on error resume next 'allows the script to continue if an error occurs.
Set fso = CreateObject("Scripting.FileSystemObject") 'creates scripting object
Set objNetwork = CreateObject("wscript.Network") 'creates an object for network scripting
'the next section maps network drives if they don't already exist
If Not fso.DriveExists("z") Then 'checks for an existing drive x
objNetwork.MapNetworkDrive "z:", "\\ptfg-fs-005p\204ISShare" 'maps network drive x to \\108wg-fs-05\204is
End If
If Not fso.DriveExists("Y") Then 'repeat of above for other drive letters
objNetwork.MapNetworkDrive "Y:", "\\108arw-fs-02\global"
End If
If Not fso.DriveExists("K") Then 'repeat of above for other drive letters
objNetwork.MapNetworkDrive "K:", "\\108arw-fs-02\apps"
End If
'the next section maps network printers
ptrName = "\\ptfg-mp-001v\204isispcl000" 'creates a variable for the part of a printer name that is a constant
ptrs = array("3","4","5","6","7","8")
for each x in ptrs 'start of loop that will create the next printer
addPtr = ptrName & x 'adds current number from loop to printer constant name
objNetwork.addWindowsPrinterConnection addPtr 'adds printer
next 'end of add printer loop
wScript.quit 'ends script
【问题讨论】:
-
通过将一些代码写入文本编辑器并将其保存在扩展名为
.ps1的文件中 :-) 您在翻译哪个部分时遇到了问题?
标签: powershell startup file-conversion