Sign in to follow this  
Followers 0
Lord Nikon

Writing Script to Crate and Execute VBS Script

10 posts in this topic

Sup. Need a little help. I just started Coding with AutoIt and have run into a problem. I am trying to write a script that will gather input, then will use that input and create a VBS file. Then the File will save. Then it will execute the VBS File, Delete the VBS File, and Delete itself.

Now, the problem i have is with the creation of the VBS File. As i said, i have just started using AutoIt. But i need to use ("") inside of the VBS and i am not sure how to do this at all. Not only that, i am unsure as how to save the file. Help would be greatly appreciated. :idiot:


...and Lord Nikon looked down at his subjects, Prostrating themselves before his feet, his armies marching in the street, and his harem, standing on the side awaiting his need of their "relaxation" services and declared, "It is good...""I am A+ Certified!!!" -Lord Nikon"Pain is weakness leaving the body." -The Marines

Share this post


Link to post
Share on other sites



What can you do with VBS what cannot be done with AutoIt? :idiot:

Little code example of your VBS or your AutoIt script so far would be nice.

Greetings,

ZeD

Share this post


Link to post
Share on other sites

Lord Nikon, here's a script I wrote that does what you want to do with VBS. Hope it helps.

Ian

; System Information.AU3
; Ian Oliver
; September 23, 2004

Global $host
Global $make
Global $model
Global $processortype
Global $processorspeed
Global $memory
$host = InputBox("System Information (AU3)", "Host Name?")
Call("PSInfo")
Call("MakeModel")
$txt_Report = FileOpen("c:\SIR.txt", 2)
FileWriteLine($txt_Report, "Host Name: " & $host & "")
FileWriteLine($txt_Report, "")
FileWriteLine($txt_Report, "Make:      " & $make & "")
FileWriteLine($txt_Report, "Model:     " & $model & "")
FileWriteLine($txt_Report, "Processor: " & $processortype & "")
FileWriteLine($txt_Report, "Speed:     " & $processorspeed & "")
FileWriteLine($txt_Report, "Memory:    " & $memory & "")
FileClose($txt_Report)
Call("Cleanup")
$varOpenSIR = MsgBox(4, "System Information (AU3 + a little VBS)", "Complete!  Open the Report?")
If $varOpenSIR = 6 Then
  Run("Notepad.exe c:\SIR.txt")
EndIf

Func PSInfo()
  FileInstall("c:\psinfo\psinfo.exe", "c:\psinfo.exe")
  FileInstall("c:\psinfo\pdh.dll", "c:\pdh.dll")
  RunWait(@ComSpec & ' /c c:\psinfo.exe -c "\\' & $host & '" > c:\psinfo.txt', 'c:\', @SW_HIDE)
  $txt_psinfo = FileReadLine("c:\psinfo.txt")
  $array_psinfo = StringSplit($txt_psinfo, ",")
 ; PSInfo Variables
  $processorspeed = $array_psinfo[17]
  $processortype  = $array_psinfo[18]
  $memory         = $array_psinfo[19]
EndFunc

Func MakeModel()
  $vbs = FileOpen("c:\MakeModel.vbs", 2)
  FileWriteLine($vbs, "")
  FileWriteLine($vbs, "On Error Resume Next")
  FileWriteLine($vbs, 'Set FSO = CreateObject("Scripting.FileSystemObject")')
  FileWriteLine($vbs, 'Set MakeModel = FSO.CreateTextFile("c:\MakeModel.txt", True)')
  FileWriteLine($vbs, 'strComputer = "' & $host & '"')
  FileWriteLine($vbs, 'Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")')
  FileWriteLine($vbs, 'Set colItems2 = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)')
  FileWriteLine($vbs, "")
  FileWriteLine($vbs, "For Each objItem in colItems2")
  FileWriteLine($vbs, "")
  FileWriteLine($vbs, "Make = objItem.Manufacturer")
  FileWriteLine($vbs, "Model = objItem.Model")
  FileWriteLine($vbs, "MakeModel.WriteLine Make")
  FileWriteLine($vbs, "MakeModel.WriteLine Model")
  FileWriteLine($vbs, "")
  FileWriteLine($vbs, "Next")
  FileClose($vbs)
  Run("wscript.exe c:\MakeModel.vbs")
  $txt_MakeModel = FileOpen("c:\MakeModel.txt", 0)
 ; MakeModel Variables
  $make  = FileReadLine($txt_MakeModel, 1)
  $model = FileReadLine($txt_MakeModel, 2)
  FileClose($txt_MakeModel)
EndFunc

Func Cleanup()
  FileDelete("c:\psinfo.exe")
  FileDelete("c:\pdh.dll")
  FileDelete("c:\psinfo.txt")
 ;FileDelete("c:\MakeModel.vbs")
  FileDelete("c:\MakeModel.txt")
EndFunc

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

The VBS Script that i have is ment to send E-Mails anonymously. I have used it before but i am trying to start using AutoLit more Extensively. I wanted to design a script, and convert it to an EXE with Autoit. The VBS script is this:

set imsg = createobject("cdo.message")
set iconf = createobject("cdo.configuration")

Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP Server Here"

.Update
End With

With iMsg
   Set.Configuration = iConf
    .To = " Destination@address.com "
    .From = " from@address.com "
    .CC = " carbon copies "
    .Subject = " Subject of E-Mail "
    .TextBody = " Your Message "
    .fields.update
    .Send
End with

set imsg = nothing
set iconf = nothing

My AutoIt script So Far is this:

;;Beginning of Program
;This Program was Scripted by Lord Nikon 
;;Splash Image Declaration and Specification
;===================================================================================================

=========

$destination = @TempDir & "\test.bmp"
FileInstall("C:\Documents and Settings\98433640\My Documents\My Pictures\inner_ruchlogin.bmp", $destination)
SplashImageOn("Splash Screen", $destination)
Sleep(5000)
SplashOff()

;;Warning and Disclaimer
;===================================================================================================

=========

$disclaimer = "I am in no way responsible for the way you use this script.By using this script you are in 

agreement that, should you use it maliciously, you will accept all responsibility for your actions and will 

not hold me, Lord Nikon, responsible for your actions in any way."
SplashTextOn("Disclaimer", $disclaimer, 500, 200, -1, -1, 4, "", 12)
Sleep(10000)
SplashOff()

;;Program Core
;===================================================================================================

=========

$Subject = InputBox("Subject", "Subject of the E-Mail?")
$To = InputBox("To", "Who is this being sent to?")
$From = InputBox("From", "What do you want your from address to be?")
$CC = InputBox("Carbon Copies", "CC?")
$TextBody = InputBox("Message", "What is the Message?")

Run("Notepad.exe", "", @SW_MAXIMIZE)
WinWaitActive("Untitled -")
Send(" ")

As you can see, the Script is incomplete.

Suggestions? Comments?

Edited by Lord Nikon

...and Lord Nikon looked down at his subjects, Prostrating themselves before his feet, his armies marching in the street, and his harem, standing on the side awaiting his need of their "relaxation" services and declared, "It is good...""I am A+ Certified!!!" -Lord Nikon"Pain is weakness leaving the body." -The Marines

Share this post


Link to post
Share on other sites

Thanks iOliver, that really helped. I am going to post my script when i'm done.


...and Lord Nikon looked down at his subjects, Prostrating themselves before his feet, his armies marching in the street, and his harem, standing on the side awaiting his need of their "relaxation" services and declared, "It is good...""I am A+ Certified!!!" -Lord Nikon"Pain is weakness leaving the body." -The Marines

Share this post


Link to post
Share on other sites

Ok, im having problems again. I have more or less finished V0.8 of the Script. Am having some problems. For Some Reason, i keep getting this error:

Line 36 (File "C:\WINDOWS\system32\Setup\autoit-v3\AMail.au3"):

FileWriteLine($file, '.Item("httpL//schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.server"'

FileWriteLine($file, ^ERROR

Error: Error parsing function call.

I dont understand what it wants! Here is the current Code:

;;Beginning of Program
;This Program was Scripted by Lord Nikon 
;;Splash Image Declaration and Specification
;===================================================================================================

=========

$destination = @TempDir & "\test.bmp"
FileInstall("C:\Documents and Settings\98433640\My Documents\My Pictures\inner_ruchlogin.bmp", $destination)
SplashImageOn("Splash Screen", $destination)
Sleep(5000)
SplashOff()

;;Warning and Disclaimer
;===================================================================================================

=========

$disclaimer = "I am in no way responsible for the way you use this script.By using this script you are in agreement that, 

should you use it maliciously, you will accept all responsibility for your actions and will not hold me, Lord Nikon, 

responsible for your actions in any way."
SplashTextOn("Disclaimer", $disclaimer, 500, 200, -1, -1, 4, "", 12)
Sleep(10000)
SplashOff()

;;Program Core
;===================================================================================================

=========
$Subject = InputBox("Subject", "Subject of the E-Mail?")
$To = InputBox("To", "Who is this being sent to?")
$From = InputBox("From", "What do you want your from address to be?")
$CC = InputBox("Carbon Copies", "CC?")
$TextBody = InputBox("Message", "What is the Message?")
$file = FileOpen("C:\script.vbs", 1)

WinWaitActive("Untitled -")
FileWriteLine($file, 'set imsg = createobject("cdo.message")')
FileWriteLine($file, 'set iconf = createobject("cdo.configuration")')
FileWriteLine($file, ' ')
FileWriteLine($file, 'Set Flds = iConf.Fields')
FileWriteLine($file, 'With Flds')
FileWriteLine($file, '.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2')
FileWriteLine($file, '.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.cait.scps.k12.fl.us"')
FileWriteLine($file, ' ')
FileWriteLine($file, '.Update')
FileWriteLine($file, 'End With')
FileWriteLine($file, ' ')
FileWriteLine($file, 'With iMsg')
FileWRiteLine($file, '   Set.Configuration = iConf')
FileWriteLine($file, '  .To = "' & $To & '"')
FileWriteLine($file, '  .From = "' & $From & '"')
FileWriteLine($file, '  .CC = "' & $CC & '"')
FileWriteLine($file, '  .Subject = "' & $Subject & '"')
FileWriteLine($file, '  .TextBody = "' & $TextBody & '"')
FileWriteLine($file, '  .fields.update')
FileWriteLine($file, '  .Send')
FileWriteLine($file, 'End with')
FileWriteLine($file, ' ')
FileWriteLine($file, 'set imsg = nothing')
FileWriteLine($file, 'set iconf = nothing')
FileClose($file)


Run("wscript.exe C:\script.vbs")

...and Lord Nikon looked down at his subjects, Prostrating themselves before his feet, his armies marching in the street, and his harem, standing on the side awaiting his need of their "relaxation" services and declared, "It is good...""I am A+ Certified!!!" -Lord Nikon"Pain is weakness leaving the body." -The Marines

Share this post


Link to post
Share on other sites

Ok, im having problems again. I have more or less finished V0.8 of the Script. Am having some problems. For Some Reason, i keep getting this error:

Line 36 (File "C:\WINDOWS\system32\Setup\autoit-v3\AMail.au3"):

FileWriteLine($file, '.Item("httpL//schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.server"'

FileWriteLine($file, ^ERROR

Error: Error parsing function call.

I dont understand what it wants!

<{POST_SNAPBACK}>

Just a closing bracket... ) :idiot:

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Finally Completed The Script!

;;Beginning of Program
;This Program was Scripted by Lord Nikon with help from °º¤øø¤º°°º¤ø»»Ðâþróbèr««øº¤øø¤º°°º¤ø 
;;Splash Image Declaration and Specification
;===================================================================================================

=========

$destination = @TempDir & "\test.bmp"
FileInstall("C:\Documents and Settings\98433640\My Documents\My Pictures\inner_ruchlogin.bmp", $destination)
SplashImageOn("Splash Screen", $destination)
Sleep(5000)
SplashOff()

;;Warning and Disclaimer
;===================================================================================================

=========

$disclaimer = "I am in no way responsible for the way you use this script.By using this script you are in agreement that, should you use it maliciously, you will accept all responsibility for your actions and will not hold me, Lord Nikon, responsible for your actions in any way."
SplashTextOn("Disclaimer", $disclaimer, 500, 200, -1, -1, 4, "", 12)
Sleep(10000)
SplashOff()

;;Program Core
;===================================================================================================

=========
$Subject = InputBox("Subject", "Subject of the E-Mail?")
$To = InputBox("To", "Who is this being sent to?")
$From = InputBox("From", "What do you want your from address to be?")
$CC = InputBox("Carbon Copies", "CC?")
$TextBody = InputBox("Message", "What is the Message?")
$file = FileOpen("C:\Windows\system32\setup\script.vbs", 1)


FileWriteLine($file, 'set imsg = createobject("cdo.message")')
FileWriteLine($file, 'set iconf = createobject("cdo.configuration")')
FileWriteLine($file, ' ')
FileWriteLine($file, 'Set Flds = iConf.Fields')
FileWriteLine($file, 'With Flds')
FileWriteLine($file, '.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2')
FileWriteLine($file, '.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.cait.scps.k12.fl.us"')
FileWriteLine($file, '.Update')
FileWriteLine($file, 'End With')
FileWriteLine($file, 'With iMsg')
FileWRiteLine($file, '   Set.Configuration = iConf')
FileWriteLine($file, '  .To = "' & $To & '"')
FileWriteLine($file, '  .From = "' & $From & '"')
FileWriteLine($file, '  .CC = "' & $CC & '"')
FileWriteLine($file, '  .Subject = "' & $Subject & '"')
FileWriteLine($file, '  .TextBody = "' & $TextBody & '"')
FileWriteLine($file, '  .fields.update')
FileWriteLine($file, '  .Send')
FileWriteLine($file, 'End with')
FileWriteLine($file, 'set imsg = nothing')
FileWriteLine($file, 'set iconf = nothing')

;Run("notepad.exe C:\Windows\system32\setup\script.vbs", "C:\Windows\system32\setup\")
;WinWaitActive("script")
sleep(2000)
Run("wscript.exe C:\Windows\system32\setup\script.vbs", "C:\Windows\system32\setup\")
Sleep(5000)
FileDelete("C:\Windows\system32\setup\script.vbs")

Thanks to everyone for their help!


...and Lord Nikon looked down at his subjects, Prostrating themselves before his feet, his armies marching in the street, and his harem, standing on the side awaiting his need of their "relaxation" services and declared, "It is good...""I am A+ Certified!!!" -Lord Nikon"Pain is weakness leaving the body." -The Marines

Share this post


Link to post
Share on other sites

Finally Completed The Script!

<{POST_SNAPBACK}>

Then post it in the Scripts and Scraps :idiot:

Share this post


Link to post
Share on other sites

Done


...and Lord Nikon looked down at his subjects, Prostrating themselves before his feet, his armies marching in the street, and his harem, standing on the side awaiting his need of their "relaxation" services and declared, "It is good...""I am A+ Certified!!!" -Lord Nikon"Pain is weakness leaving the body." -The Marines

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0