Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


WshShell.Run Cannot Run String With Spaces

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,64689
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> WshShell.Run Cannot Run String With Spaces
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 WshShell.Run Cannot Run String With Spaces - 10/1/2008 2:33:00 AM   
  SytnerIT

 

Posts: 12
Score: 0
Joined: 9/2/2008
Status: offline
Hi All

I am having what feels like a basic problem trying to run an executable using WshShell.Run .

The path to the executable does contain a space which is causing all the problems.

The script is below could someone please assist before I tear my hair out.

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run  "C:\STS\Update\Auda Enterprise Gold\AudaEnterpriseGold.exe"

Cheers

Rob

SytnerIT
 
 
Post #: 1
 
 RE: WshShell.Run Cannot Run String With Spaces - 10/1/2008 4:54:43 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
Best way to deal with strings that contain spaces.

*Echo the line before you run it.
This will ensure you have your quotes setup correctly.

You can either use CHR(34) for representation of the quotes, or use double "".
It all really goes down to preference.

Set WshShell = CreateObject("WScript.Shell")
'Comment out your line to test for quotes covering string
'WshShell.Run  "C:\STS\Update\Auda Enterprise Gold\AudaEnterpriseGold.exe"

wscript.echo "Using double-quotes:" & VBCRLF & """C:\STS\Update\Auda Enterprise Gold\AudaEnterpriseGold.exe"""
wscript.echo "Using CHR(34) for quotes:" & VBCRLF & CHR(34) & "C:\STS\Update\Auda Enterprise Gold\AudaEnterpriseGold.exe" & CHR(34)

Once you see the entire string has quotes around it, you are ready to RUN.

(in reply to SytnerIT)
 
 
Post #: 2
 
 RE: WshShell.Run Cannot Run String With Spaces - 10/1/2008 8:11:11 PM   
  SytnerIT

 

Posts: 12
Score: 0
Joined: 9/2/2008
Status: offline
Fantastic, thanks.

Don't know if this bad form, if so please say and I'll create a new enquiry, but I am having problems with buttons in an HTA.

The subprocess that runs when a button is pressed contains the WshShell.Run (that you just helped with) and starts an executable - this works perfectly.
After that I would like the button to disable.

The subprocess executes differently depending on which button is pressed i.e different button means different argument given to it.

I am trying to write one line of code that disables the button pressed, my subprocess knows which button was pressed, so I thought I should be able to script a disable event.
In short I am trying to use a variable in the line - ButtonNumber_Button.Disable = true

This is the subprocess below:

Sub Run(intSoftwareNumber)
   WshShell.Run  CHR(34) & "C:\STS\Update\" & astrSoftware(0, intSoftwareNumber) & "\" & astrSoftware(1, intSoftwareNumber) & ".exe" & CHR(34)
   astrSoftware(1, intButtonNumber) & "_Button.Disabled" = True
End Sub

If you have any suggestions that would much appreciated.

Cheers
Rob  SytnerIT

(in reply to Country73)
 
 
Post #: 3
 
 RE: WshShell.Run Cannot Run String With Spaces - 11/4/2008 6:29:34 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
Sorry, been away from here for a while.
It's been a LONG time since I've really messed with HTA's. Been doing most of that through AutoIT, which I like all the control it offers.
I'll see if I can dig up an old HTA, or work through some code for you.

(in reply to SytnerIT)
 
 
Post #: 4
 
 RE: WshShell.Run Cannot Run String With Spaces - 11/4/2008 6:54:20 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
Couldn't find a small HTA to show, so threw this one together.

Line you are looking for is:  btn1.Disabled = True


      

(in reply to Country73)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> WshShell.Run Cannot Run String With Spaces Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts