Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

tâches planifiées

2 réponses
Avatar
Arnaud SCHMITT
Salut à tous,
Je cherche le moyen de planifier avec les tâches planifiées des scripts VBS
et des applis VB.
Le problème est que la tâche s'arrête sur quelques instructions. Je ne
comprend pas pourquoi. Les droits sont évidemment en admin ou admin domaine.

Le script lane une instance XL, après avoir récupéré des info sur la print
voulue, et imprime un graphique sur la première page.
Pas de Pb pour le lancer manuellement mais en tâche planifier = blocage.

Help please. Ci-dessous le script :




'==========================================================================
'on récupère le nom de l'imprimante
'==========================================================================
Dim strNomPrint

strNomPrint="q12ad1fa"

dim strDescription

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
If objPrinter.PortName=strNomPrint Then
strDescription=objPrinter.DeviceID
End if
Next

'==========================================================================
'on retrouve le winspool de l'imprimante strDescription
'==========================================================================
Dim winspool

const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_PrinterConfiguration")
For Each objPrinter in colInstalledPrinters

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Devices"
strValueName = objPrinter.Name
If strValueName=strDescription then
oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
winspool=mid(dwValue,Len(dwValue)-4,5)
end if

Next

Set appExcel = WScript.CreateObject("EXCEL.application")
appExcel.Visible = true


Dim tabServer(10)
tabServer(0)="server1"
tabServer(1)="server2"
tabServer(2)="server3"
tabServer(3)="server4"
tabServer(4)="server5"
tabServer(5)="server6"
tabServer(6)="server7"
tabServer(7)="server8"
tabServer(8)="server9"
tabServer(9)="server10"

For i = 0 To 9

'Ouverture d'un fichier Excel
Set wbExcel = appExcel.Workbooks.Open("\\server\" & tabServer(i) &
"\fichier.xls")
'wsExcel correspond à la première feuille du fichier

Set wsExcel = wbExcel.Worksheets(1)

appExcel.ActiveSheet.ChartObjects("Graphique 1").Activate
appExcel.ActiveChart.ChartArea.Select

'impression sur imp secrétariat DI
' appExcel.ActivePrinter = strDescription & " sur " & winspool
' appExcel.ActiveChart.PrintOut , , , , strDescription & " sur " &
winspool

'impression print par défaut
appExcel.ActiveChart.PrintOut

appExcel.Workbooks("fichier.xls").Close false,"fichier.xls",False

Next

appExcel.quit
Set appExcel = Nothing

'WScript.Echo("Impressions lançées.")

2 réponses

Avatar
chris
moi je voudrais planifier une tâche avec le taskmanager de XP, mais je ne
sais pas comment envoyer la commande pour exécuter at.exe avec un vbscript a
l'interieur d'un html

si vous avez une idée
Avatar
Golgoth
Bonjour, j'ai essayé chez moi ton programme en local, en mettant le meme
user pour la tache planifié que le user en cours de session, ca marche.
Par contre si je mets un autre user que celui en cours cela ne marche pas,
il y a blocage (pourtants les users ont le meme privilège, je suis ur XP)

je ne sais pas si cela t'aidera...