
Detalhes
- SO: Windows 7
- UAC: Desativado
- O quê: estou executando um VBScript que extrai um arquivo zip e o vbscript é iniciado pelo serviço Jenkins. Preciso usar o VBScript, e não posso usar ferramentas externas que não existem em uma instalação limpa do Windows.
- Problema: Se o serviço estiver sendo executado como NT Authority\SYSTEM OU como administrador local, recebo uma mensagem de erro na tela relacionada à descompactação do vbscript. Executar o script como usuário atual não produz nenhum problema. A mensagem de erro é intitulada: Detecção de serviços interativos. O texto da caixa de diálogo dizUm programa em execução neste computador está tentando exibir uma mensagem.
Se você clicar em "visualizar a mensagem", você verá uma caixa de diálogo muito antiga intitulada:Acesso à pasta negadocom o textoVocê precisará fornecer permissão de administrador para copiar esta pasta.
Parece que seria de alguma forma relacionado ao UAC, exceto que o UAC está supostamente desativado.
- Roteiro:
Const noProgressYesAll = &H14
Dim objFSO
Set objFSO = CreateObject("scripting.filesystemobject")
zipFile = "C:\test.zip"
unzipPath = "C:\test\"
WScript.Echo "ZIPEXTRACTDIR: " & unzipPath
WScript.Echo "ZIPFILE: " & zipFile
If objFSO.FileExists(zipFile) Then
If objFSO.FolderExists(unzipPath) Then
Set objShell = CreateObject( "Shell.Application" )
Set objSource = objShell.NameSpace(zipFile)
If objSource is Nothing Then
printMsg "Invalid Zip File " & zipFile
Else
unzipLog = zipFile&".log"
printMsg "Logging to " & unzipLog
Set objLog = objFSO.OpenTextFile(unzipLog,fsoForWriting,True)
Set objTarget = objShell.NameSpace(unzipPath)
objTarget.CopyHere objSource.Items, noProgressYesAll
For Each item in objSource.Items
printMsg "Extracted: " & unzipPath&item.Name
objLog.Write unzipPath&item.Name & vbCrLf
If objFSO.FileExists(unzipPath&item.Name) Then
printMsg "Verified File: " & unzipPath&item.Name
Else
If objFSO.FolderExists(unzipPath&item.Name) Then
printMsg "Verified Folder: " & unzipPath&item.Name
End If
End If
Next
objLog.Close
End If
Else
printMsg "Directory does not exist: " & unzipPath
End If
Else
printMsg "Zip file does not exist: " & zipFile
End If
Set objLog = Nothing
Set objSource = Nothing
set objShell = Nothing
set objTarget = Nothing