Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

startovanje xls fajlova u VB skripti (jedan po jedan)

[es] :: Skript jezici :: startovanje xls fajlova u VB skripti (jedan po jedan)

[ Pregleda: 31727 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

anon70939

Član broj: 70939
Poruke: 2823



+6883 Profil

icon startovanje xls fajlova u VB skripti (jedan po jedan)23.05.2014. u 08:11 - pre 119 meseci
Imam neke xls izvestaje koji se izvrsavaju, snimaju na neko mesto, pa posle VBS skripta pokupi te fajlove i posalje na neke mail adrese.

Ovako recimo izgleda Batch skripta
Code:
@echo off
title Please Wait...
start C:\IT\1_smena\Reports\MR.xls
start C:\IT\1_smena\Reports\DS.xls
start C:\IT\1_smena\Reports\HT.xls
start C:\IT\1_smena\Reports\PO.xls
start C:\IT\1_smena\Reports\MTD.xls

PING 1.1.1.1 -n 1 -w 5000 >NUL
t:\IT\1_smena\Daily_0720.vbs

PING 1.1.1.1 -n 1 -w 5000 >NUL
exit


A VBS skripta ovako
Code:

Set objOutlook = CreateObject("Outlook.Application")
   Set objMail = objOutlook.CreateItem(0)
   objMail.To = "[email protected][email protected]"
   objMail.cc = "[email protected]"
   objMail.Subject = "Dnevni Izvestaji"
   objMail.Body = "Pozdrav," & vbNewLine & "IT Kragujevac"
   objMail.Attachments.Add("t:\IT\1_smena\Reports\TMP\MR" & " " & Day(Now()) & "-" & MonthName(Month(Now()), 1) & ".xls")
   objMail.Attachments.Add("t:\IT\1_smena\Reports\TMP\DS" & " " & Day(Now()) & "-" & MonthName(Month(Now()), 1) & ".xls")
   objMail.Attachments.Add("t:\IT\1_smena\Reports\TMP\HT" & " " & Day(Now()) & "-" & MonthName(Month(Now()), 1) & ".xls")
   objMail.Attachments.Add("t:\IT\1_smena\Reports\TMP\PO" & " " & Day(Now()) & "-" & MonthName(Month(Now()), 1) & ".xls")
   objMail.Attachments.Add("t:\IT\1_smena\Reports\TMP\MTD" & " " & Day(Now()) & "-" & MonthName(Month(Now()), 1) & ".xls")
   objMail.Send
   Set objMail = Nothing
   Set objOutlook = Nothing



Ranije sam u XLSu koristio makro koji bi odmah cim se izvrsi fajl, automatski posalje na mailove, ali kad se nagomilalo brdo izvestaja, ili jedan kolega da otkaz, onda moram da trazim fajlove koji su isli njemu, da ih otvaram jedan po jedan i ispravljam.
Iz tog razloga bih hteo na gore pomenuti nacin da saljem.
Ali bih zeleo da pojednostavim jos vise.

Odnosno da ne upotrebljavam i batch i vbs nego jedno od ta dva.

Za batch nisam uspeo da nadjem neki jednostavni nacin za slanje mailova, a to bi mi mozda najvise i odgovaralo.

A za VBS nisam nasao neki nacin za pokretanje fajlova.
Tj. sa batch skriptom kad napravim skriptu na gore pomenuti nacin, onda se izvrsava fajl po fajl. Prvo se startuje i izvrsi prvi, pa kad se zavrsi tek onda pokrece i sledeci i tako dalje...
Za VBS nisam nasao na netu neki slican nacin, nego mi skripta pokrene sve fajlove odjednom pa mi racunar zabode...

Dajte neki nacin da sa batch skriptom saljem mail ili sa VBS skriptom pokrecem fajlove jedan po jedan.

Da napomenem da kod ove VBS skripte mi se svidja sto ne mora da mi bude ukljucen Outlook da bi se mail poslao. Sve odradi u pozadini u delicu sekunde
 
Odgovor na temu

anon70939

Član broj: 70939
Poruke: 2823



+6883 Profil

icon Re: startovanje xls fajlova u VB skripti (jedan po jedan)26.05.2014. u 09:35 - pre 119 meseci
I bas niko da ne zna? :)

Pa ne verujem da je ovo baš teško... Jedino ako sam konfuzno objasnio šta mi treba.

Dakle da pomoću VBS skripte pokrećem jedan po jedan fajl kao što batch radi. Da mi ne otvori sve xls-ove odjednom :)
 
Odgovor na temu

rajco

Član broj: 19348
Poruke: 1020

Sajt: rajco.me/blog


+45 Profil

icon Re: startovanje xls fajlova u VB skripti (jedan po jedan)26.05.2014. u 10:15 - pre 119 meseci
Powershell može i jedno i drugo vrlo lako, takođe bez aktivnog outlook klijenta.
rajco.me/blog

 
Odgovor na temu

anon70939

Član broj: 70939
Poruke: 2823



+6883 Profil

icon Re: startovanje xls fajlova u VB skripti (jedan po jedan)26.05.2014. u 14:18 - pre 119 meseci
Mozes li bar dati primer kako da pokrenem 2 razlicita fajla jedan posle drugog?
 
Odgovor na temu

rajco

Član broj: 19348
Poruke: 1020

Sajt: rajco.me/blog


+45 Profil

icon Re: startovanje xls fajlova u VB skripti (jedan po jedan)26.05.2014. u 15:15 - pre 119 meseci
PS podržava komande iz cmd-a, tako da se možeš poslužiti već napisanim start, dok za čekanje možeš iskoristiti start-sleep.
rajco.me/blog

 
Odgovor na temu

anon70939

Član broj: 70939
Poruke: 2823



+6883 Profil

icon Re: startovanje xls fajlova u VB skripti (jedan po jedan)26.05.2014. u 21:40 - pre 119 meseci
ako već znaš, i odgovaraš, što ne odgovoriš na pitanje...
Mogao si da daš primer 2 reda koda za PS kao što sam pitao... Ovako i ne pomažeš preterano osim što mogu da se divim tvom znanju...


Kako čitam sad kako funkcioniše start-sleep, ako sam dobro razumeo treba da orderim koliko u sekundama da traje taj proces?

Meni to ne znači ništa. Jer ne traje mi izvršavanje izveštaja svaki put isto...

Ovi xls-ovi koji meni trebaju povlače podatke iz Oracle baze. I u zavisnosti od veličine izveštaja, uvek je potrebno različito vreme izvršavanja svakog.

Kao što rekoh, kod batch-a drugo startovanje xls-a mi ne počinje dok se prethodni ne završi.
VBS je drugačije i ne igra mi ulogu...

Verujem da VBS ima neku prostu funkciju oko toga, ali nisam uspeo da izguglam i obratio sam se ovde za pomoć...

edit:
mozda PS moze sa wait-process
 
Odgovor na temu

SPIN28
Phoenix

Član broj: 312438
Poruke: 4
*.dynamic.isp.telekom.rs.



Profil

icon Re: startovanje xls fajlova u VB skripti (jedan po jedan)30.05.2014. u 22:45 - pre 119 meseci
Cmdlet start-process ima wait parametar koji radi to sto tebi treba, ceka da se proces zavrsi da bi nastavio sa daljim izvrsavanjem
 
Odgovor na temu

rgdrajko
Beograd

Član broj: 117734
Poruke: 710
*.opera-mini.net.



+3 Profil

icon Re: startovanje xls fajlova u VB skripti (jedan po jedan)14.11.2014. u 01:37 - pre 114 meseci
http://www.robvanderwoude.com/email.php


Send e-mails by batch

Batch generated e-mail messages were mentioned before in my Solutions found in alt.msdos.batch page.

The January 2000 issue of Blaise, the Dutch HCC Pascal User Group's magazine, contained an article about sending e-mail with Delphi. The article contained more information on the command strings used to send e-mail.

The general format is:

mailto:to?subject=subject&cc=cc_address&bcc=bcc_address&body=message_body
to_address The (escaped) e-mail address of the recipient; allowed formats:
[email protected]
• Full%20Name<[email protected]>
subject The (escaped) subject field of the message
cc_address The (escaped) "carbon copy" e-mail address; allowed formats:
[email protected]
• Full%20Name<[email protected]>
bcc_address The (escaped) "blind carbon copy" e-mail address; allowed formats:
[email protected]
• Full%20Name<[email protected]>
message_body The actual message body (escaped too)


Notes: (1) All parameters mentioned need to be "escaped", i.e. spaces should be replaced by %20, carriage return/line feeds by %0D%0A, double quotes by %22, single quotes by %27, backslashes by %5C, less than by <, greater than by >, and ampersands by &.
For batch files and command line use, unless the entire string is enclosed in doublequotes, the percent signs in the "escape sequences" themselves must also be replaced by double percent signs: so in the end spaces should be replaced by %%20, carriage return/line feeds by %%0D%%0A, etcetera.
(2) The commands shown here only create a message.
To send it you still need to press the Send button yourself.
Check out the links to third party command line e-mail utilities at the bottom of this page if you need to send e-mail unattended.


To use this type of command in batch files we need to:

precede the string with the START command
replace every single percent sign ( % ) by double percent signs ( %% )
"escape" ampersands ( & ) with carets ( ˆ )
limit the length of the mailto string to the maximum allowable command line length minus 6 (leaving a maximum of 121 characters for MS-DOS, or 249 characters for Windows NT 4/Windows 2000, or 2035 for Windows XP)


Examples:



START mailto:[email protected]?subject=Test%%20messageˆ&[email protected]ˆ&body=Hi,%%0D%%0A%%0D%%0AThis%%20is%%20an%%20automatically%%20created%%20message.%%0D%%0A%%0D%%0ABye
This command will create a message to [email protected], with a carbon copy to [email protected], with the words "Test message" in the subject field.
The message itself will consist of the following text:

Hi,

This is an automatically created message.

Bye


The following NT only batch file will check if the correct network drive mappings have been made.
If not, an e-mail message to the helpdesk is generated (assuming the e-mail software is available without the mappings). The user can add more information before actually sending it.

@ECHO OFF
SET ERRORS=0
:: Use your own mappings and search strings here
NET USE P: | FIND /I "%username%" >NUL 2>NUL
IF ERRORLEVEL 1 CALL :ErrorMsg P:
NET USE S: | FIND /I "system" >NUL 2>NUL
IF ERRORLEVEL 1 CALL :ErrorMsg S:
:: Create an e-mail message if any errors were detected
IF %ERRORS% GEQ 1 CALL :Mail
:: Clear variables used in this batch file
FOR %%A IN (BODY DATE ERRORS LINE MESSAGE TIME) DO SET %%A=
GOTO :EOF

:ErrorMsg
SET /A ERRORS = %ERRORS% + 1
NET USE %1 >NUL 2>NUL
IF ERRORLEVEL 1 (
SET BODY=%BODY%%%0D%%0ADrive%%20%1%%20not%%20mapped
GOTO :EOF
)
FOR /F "TOKENS=3* DELIMS= " %%A IN ('NET USE %1 ˆ| FIND "Local name"') DO SET MESSAGE=Drive%%20%%A%%20mapped%%20to%%20
:: Replacement of backslashes "\" by "%%5C"
:: prevents interpretation of "\n" as CR/LF
FOR /F "TOKENS=3,4* DELIMS=\ " %%A IN ('NET USE %1 ˆ| FIND "Remote name"') DO SET MESSAGE=%MESSAGE%%%5C%%5C%%A%%5C%%B
SET BODY=%BODY%%%0D%%0A%MESSAGE%
GOTO :EOF

:Mail
FOR /F "TOKENS=2*" %%A IN ('DATE/T') DO SET DATE=%%A
FOR /F %%A IN ('TIME/T') DO SET TIME=%%A
START mailto:[email protected]?subject=Drive%%20mapping%%20errorˆ&body=At%%20%DATE%,%%20%TIME%,%%20user%%20%USERNAME%%%20encountered%%20the%%20following%%20drive%%20mapping%%20error(s)%%20on%%20%COMPUTERNAME%:%%0D%%0A%BODY%
GOTO :EOF
rgdrajko
 
Odgovor na temu

[es] :: Skript jezici :: startovanje xls fajlova u VB skripti (jedan po jedan)

[ Pregleda: 31727 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.