Jump to content

Execute VBS in a variable location?


Recommended Posts

I'm struggling to launch a VBS file via autoit using RunWait.  Due to the nature of the deployment tool I am using for said script, I only know that the .vbs files will be in the same directory as my AutoIt-generated .exe, but not what that path will be.  The path will look something like this:

c:\programdata\vendor\lots\of\folders\randomnumber

This is generated during deployment and I have no way of predicting the path - therefore, I am not sure how to call back to "same directory" in order to successfully launch the .vbs.

This line is as close as I have gotten - this fires off the cmd window, but it closes immediately with out information, and the .vbs is not launched.

RunWait (@ComSpec & " /c" & 'cscript.exe WORKPLEASE.vbs ALL /Q /NoCancel')

I thought /c might be the problem, but leaving out the /c element causes me not to even see the momentary CMD window flash by.  Any help will be greatly appreciated, and thanks in advance.

Link to post
Share on other sites

Add a space after " /c"

RunWait (@ComSpec & " /c " & 'cscript.exe WORKPLEASE.vbs ALL /Q /NoCancel')

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Then lets try to keep the window open:

RunWait (@ComSpec & " /k " & 'cscript.exe WORKPLEASE.vbs ALL /Q /NoCancel')

/c stands for "close the window", /k for "keep the window open".

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Thanks Water and Subz.

Combining those two got the scripts to fire and leave the screen up for troubleshooting - but then for no explicable reason, the VBS gives a permissions error on trying to remove some registry keys.  This is extremely confusing, as the script works both when called manually from a command line or from a batch.  Just for grins, I even moved the batch into the auto-deployment folder where the .exe landed, and the batch works great... but calling it via the EXE I made with AutoIt doesn't.

I'll dig deeper into that, appreciate the help that at least got me this far.

Link to post
Share on other sites

Let me try #RequireAdmin - the .vbs I'm trying to run isn't one I made myself, unfortunately.  It's one of MS's pre-published Office Removal .VBS monstrosities.  3926 lines, more than a minor effort to convert to AutoIt.  Happy to provide the file if you're feeling froggy, but it seems effort-prohibitive to me.

**Edit - # RequireAdmin didn't change the outcome.  Just for grins, used psexec to kick the .exe off under the system account, same issue.

Edited by vyperhand
Updated information.
Link to post
Share on other sites

Not sure if this would help, but here is what I used when upgrading our Office 2003/2007 clients to Office 2013

#RequireAdmin
Opt("ExpandVarStrings", 1)
;~ Uninstall Office 2003
If RegRead('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90110409-6000-11D3-8CFE-0150048383C9}', 'DisplayName') Then
    RunWait('@ComSpec@ /c cscript "@ScriptDir@\OffScrub03.vbs" PIA,PROPLUS /S /OSE /BYPASS 1 /NOCANCEL /Quiet', '', @SW_HIDE)
EndIf
;~ Uninstall Office 2007
If RegRead('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90120000-0011-0000-0000-0000000FF1CE}', 'DisplayName') Then
    RunWait('@ComSpec@ /c cscript "@ScriptDir@\OffScrub07.vbs" EXPDFXPS,PIA,PROPLUS /S /OSE /BYPASS 1 /NOCANCEL /Quiet', '', @SW_HIDE)
EndIf

 

Link to post
Share on other sites

Yep, that looks familiar all right.

 

#RequireAdmin
RunWait (@ComSpec & " /c " & 'cscript.exe offscrub07.vbs ALL /Q /NoCancel')
Run (@ComSpec & " /c " & "shutdown /r /t 30 /d P:4:1")

But for some reason, the first step of the VBS fails with a perms error regarding the registry when called from AutoIt.  Still digging into what might be causing that.  So the VBS fails, the sandbox system reboots, and I'm back to the drawing board.  I'll dig into this more tomorrow for sure.

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Zaoka
      HI,
      for couple of years I'm using  Jos script for sending reports, email with excel attachment. But from last week i'm getting this error when sending excel or word attachment
      message has lines too long for transport jpeg, pdf works with no problems, any sugestion ?
    • By diepfeile
      I'm using the following:
      Autoit 3.3.14.5
      newly installed Beta 3.3.15.5
      SQlite version 3380000 aka 3.38.0
      I put sqlite3.dll and sqlite3_x64.dll in C:\Windows\System32 since many scripts depend on them.


      I extended the output of _SQLite_Startup()
      with:
      ConsoleWrite("@AutoItX64 " & @AutoItX64 & @CRLF) ConsoleWrite("$sDll_Filename " & $sDll_Filename & @CRLF) ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)

      Also using the script from https://www.autoitscript.com/autoit3/docs/libfunctions/_SQLite_Startup.htm for testing.

       
      >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "R:\Download\aasdf.au3" @AutoItX64 0 $sDll_Filename sqlite3.dll _SQLite_LibVersion=0 >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "R:\Download\aasdf.au3" @AutoItX64 1 $sDll_Filename sqlite3_x64.dll _SQLite_LibVersion=3.38.0 >Running:(3.3.15.5):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "R:\Download\aasdf.au3" @AutoItX64 0 $sDll_Filename sqlite3.dll _SQLite_LibVersion=0 >Running:(3.3.15.5):C:\Program Files (x86)\AutoIt3\Beta\autoit3_x64.exe "R:\Download\aasdf.au3" @AutoItX64 1 $sDll_Filename sqlite3_x64.dll _SQLite_LibVersion=3.38.0


      Why doesn't it work in 32bit, despite me having the 32bit sqlite.dll? Autoit urges running scripts in 32bit mode and Scite starts scripts just in 32bit mode without the flag?
      With #AutoIt3Wrapper_UseX64=Y it just works, both normal Autoit and beta!
      sqlite3.dll sqlite3_x64.dll
    • By Iraj
      Hello Team, Greetings!
      Is there any way to run any 3rd party application silently in background without the GUI getting in the front ?
      I was implementing angry-ip scanner with autoit & wanted the angry-ip application to run in background quietly as I am copying its output to other file on completion. is there any way to achieve my query?
      Below is code I tried: 
      $range = "192.168.0.1 192.168.0.255" ShellExecuteWait("C:\Windows\DDM\ipscan.exe","-f:range "&$iprange&" -q -o C:\temp\ScanResults.csv","","open",@SW_HIDE) Thanks!
    • By Iraj
      Hi Team,
      Greetings!
       
      One silly doubt, I need to pass one parameter using RunWait to write an output to a file using Cmd Line, but the below isn't writing to the file specified. Kindly assist.
      $pass = $CmdLine[1] $CMD = "C:\Progra~1\bin\Encrypt.exe" &$pass& " > C:\temp\pwd.txt" #write the parameter $pass in C:\temp\pwd.txt RunWait(@ComSpec & " /c " & $CMD,"",@SW_HIDE) Thank you!!
    • By PeterVerbeek
      This topic give you access to an AutoIt functions library I maintain which is called PAL, Peter's AutoIt Library. The latest version 1.26 contains 214 functions divided into these topics:
      window, desktop and monitor GUI, mouse and color GUI controls including graphical buttons (jpg, png) logics and mathematics include constants string, xml string and file string dialogues and progress bars data lists: lists, stacks, shift registers and key maps (a.ka. dictionaries) miscellaneous: logging/debugging, process and system info Change log and files section  on the PAL website (SourceForge).
      A lot of these functions were created in the development of Peace, Peter's Equalizer APO Configuration Extension, which is a user interface for the system-wide audio driver called Equalizer APO.
×
×
  • Create New...