I have a batch file that "starts" the following .vbs file:
strComputer = "serverA"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name=z:\serverpath\x\y\z'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In FileList
strDate = Left(objFile.CreationDate, 8)
strNewName = objFile.Drive & objFile.Path & _
strDate & "." & "bak"
strNameCheck = Replace(strNewName, "\", "\\")
i = 1
Do While True
Set colFiles = objWMIService.ExecQuery _
("Select * from Cim_Datafile Where Name = '" & strNameCheck & "'")
If colFiles.Count = 0 Then
errResult = objFile.Rename(strNewName)
Exit Do
Else
i = i + 1
strNewName = objFile.Drive & objFile.Path & _
strDate & "_" & i & "." & "bak"
strNameCheck = Replace(strNewName, "\", "\\")
End If
Loop
Next
When run locally it works perfect, however when i run this with the batch file (quick breakdown of batch file-- 1.maps network drive 2."starts" the vbs file 3.returns to batch file and copies files to drive mapping) it fails with permission denied in the vbs error pop up box. So I want to be able to have the above vbs file prompt for network logon. Any ideas?
Thanks in advance
The Geek
Dont be afraid to share what you know. There are no losers in our arena, only self rightous monkeys atop their own tree.
strComputer = "serverA"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name=z:\serverpath\x\y\z'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In FileList
strDate = Left(objFile.CreationDate, 8)
strNewName = objFile.Drive & objFile.Path & _
strDate & "." & "bak"
strNameCheck = Replace(strNewName, "\", "\\")
i = 1
Do While True
Set colFiles = objWMIService.ExecQuery _
("Select * from Cim_Datafile Where Name = '" & strNameCheck & "'")
If colFiles.Count = 0 Then
errResult = objFile.Rename(strNewName)
Exit Do
Else
i = i + 1
strNewName = objFile.Drive & objFile.Path & _
strDate & "_" & i & "." & "bak"
strNameCheck = Replace(strNewName, "\", "\\")
End If
Loop
Next
When run locally it works perfect, however when i run this with the batch file (quick breakdown of batch file-- 1.maps network drive 2."starts" the vbs file 3.returns to batch file and copies files to drive mapping) it fails with permission denied in the vbs error pop up box. So I want to be able to have the above vbs file prompt for network logon. Any ideas?
Thanks in advance
The Geek
Dont be afraid to share what you know. There are no losers in our arena, only self rightous monkeys atop their own tree.