Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Missing logon

Status
Not open for further replies.

MrGeek

MIS
Nov 3, 1999
113
US
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.
 
Meant when I run this from computerA :) near the bottom prior to the "quick breakdown"


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.
 
[1] The "else" part seems incomplete?
[2]>Meant when I run this from computerA :) near the bottom prior to the "quick breakdown"
Can't figure out what it means.
[3]>So I want to be able to have the above vbs file prompt for network logon. Any ideas?
If network credential is the problem rather than anything else, you can always launch the vbs from the batch with runas. Something like this, figuratively.
[tt] runas /netonly /user:domainname\username cmd /c cscript.exe //b //nologo xyz.vbs[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top