使用不同的用户凭据运行脚本

使用不同的用户凭据运行脚本

我有一个创建文件夹和子文件夹的 VBS 脚本。

dim filesys, newfolder, newfolderpath, number, address
number=inputbox("Please enter the request number to create","Request number")
address=inputbox("Please enter the damage address","Damage address")
'update the folder path in the below line
newfolderpath="\\cads01\new projects\2020\"
newfolderpath = newfolderpath +number +" - " +address
set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists(newfolderpath) Then
Set newfolder = filesys.CreateFolder(newfolderpath)
Set newfolder = filesys.CreateFolder(newfolderpath+ "\Photos")
Set newfolder = filesys.CreateFolder(newfolderpath+ "\Factures")
Set newfolder = filesys.CreateFolder(newfolderpath+ "\PO's - Devis")
Set newfolder = filesys.CreateFolder(newfolderpath+ "\Correspondance")
Set newfolder = filesys.CreateFolder(newfolderpath+ "\Documents Facturation")
msgbox "Folders are created!"
End If

它将由用户运行。我已为用户设置权限,因此他们无法创建文件夹或从脚本创建的文件夹中删除任何文件。

问题是,当他们运行脚本时,文件夹的创建被“拒绝权限”。我希望脚本可以以具有创建文件夹权限的另一个用户身份运行,而无需输入任何凭据。基本上,脚本将以具有权限的用户身份运行。

相关内容