Login | |
|
 |
RE: Newbie Question - Quotes within a objShell.exec - 3/10/2008 12:24:28 PM
|
|
 |
|
| |
dm_4ever
Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
Have you looked at the Frequently Asked Stuff post? ....towards the end of the post you'll find what you need...it is using the Run method, but the same applies to the Exec method.
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Newbie Question - Quotes within a objShell.exec - 3/10/2008 1:21:46 PM
|
|
 |
|
| |
dm_4ever
Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
WScript.Echo "X:\Imagex.exe /apply " & AddQuotes("Y:\Operating Systems\Vista Reference Image\VistaImage.wim") & " 1 C:" Function AddQuotes(strText) AddQuotes = Chr(34) & strText & Chr(34) End Function
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Newbie Question - Quotes within a objShell.exec - 3/10/2008 3:37:29 PM
|
|
 |
|
| |
dm_4ever
Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
In that case I would suggest using the Run method Dim objShell : Set objShell = CreateObject("WScript.Shell") objShell.Run "X:\Imagex.exe /apply " & AddQuotes("Y:\Operating Systems\Vista Reference Image\VistaImage.wim") & " 1 C:" Function AddQuotes(strText) AddQuotes = Chr(34) & strText & Chr(34) End Function
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Newbie Question - Quotes within a objShell.exec - 3/11/2008 12:20:16 AM
|
|
 |
|
| |
ebgreen
Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
|
Here is how I feel about .Run vs. .Exec. I always use .Run when possible because I can hide any command prompt window in the background. The exception is when I need to interact with the command prompt that is created. In that case I use .Exec.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Newbie Question - Quotes within a objShell.exec - 3/11/2008 1:21:56 AM
|
|
 |
|
| |
dm_4ever
Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
quote:
Exec Method: Runs an application in a child command-shell, providing access to the StdIn/StdOut/StdErr streams Since GreatBarrier86 has no need to StdIn, StdOut, or StdErr then I don't see a need to use it...plus I agree with what ebgreen mentioned as well...you can easily hide the command prompt window with the Run method. In the last two weeks or so there has been at least 2 people who have asked how they can hide the command prompt when they use the Exec method....in the end they both get the job done and it may be a matter of personal preference.
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Newbie Question - Quotes within a objShell.exec - 3/11/2008 4:27:00 AM
|
|
 |
|
| |
ehvbs
Posts: 2173
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
|
Hi GreatBarrier86, in many languages you'l have to enclose the list of arguments to a function (sub, method, procedure, ..) in parameter list (). In VBScript such () are allowed only if you assign the return value of the called code to a variable. If you look at the "MapNetworkDrive Method" topic in the VBScript Docs, you'll see that the first presentation object.MapNetworkDrive(strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword]) is wrong/misleading (probably because the documenters were in JScript mode). The sample is correct: Dim WshNetwork Set WshNetwork = WScript.CreateObject("WScript.Network") WshNetwork.MapNetworkDrive "E:", "\\Server\Public" If you add those () here, you'll get a "Cannot use parentheses when calling a Sub" error. This nasty peculiarity of VBScript syntax is blurred by (a) the Call keyword - if you use Call, you must use parameter list () (b) the use of "pass me by value" parentheses: if you want to pass an argument by value, you put it in (): Dim WshNetwork : Set WshNetwork = WScript.CreateObject("WScript.Network") Dim sDrive : sDrive = "E:" WshNetwork.MapNetworkDrive (sDrive), "\\Server\Public" is syntactically correct (while not very useful/senseful). WShell.Run ( sCmd ) will 'work', but the () doesn't mean, what the unaware may think. Putting those () in a Sub call is a F:requently D:one E:rror; that's why I use every opportunity to point this out (I beg the pardon of regular readers/posters). Thanks for your insistence on an explanation (and providing me with an opportunity to be pedantic) ehvbs
|
|
| |
|
|
|
 |
RE: Newbie Question - Quotes within a objShell.exec - 3/11/2008 4:48:01 AM
|
|
 |
|
| |
ebgreen
Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
|
WSF files are essentially a way to bundle your scripts together into one file. Since WSF files are script engine agnostic, you can put any script into them that you have a valid engine installed for. So in one WSF file you could have a VBSCript, a jscript, and a perl script (assuming you have perl installed) living side by side and you could execute any of them from the command prompt by calling the WSF file and giving it a parameter that indicates which script(s) to run. I do not know if WSF files support powershell or not, but I may try to find out if I have time.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Newbie Question - Quotes within a objShell.exec - 3/11/2008 5:01:12 AM
|
|
 |
|
| |
ebgreen
Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
|
I have confirmed that powershell is not currently supported in WSF files. I would expect that to change. If you are writing VBS then use.vbs. The WSF file is XML that encapsulates VBS, Jscript, or Perl script. Just saving a file with a .wsf does not make it a WSF file. As for further VBScript development, there will not be a new version of the script engine unless one is required for critical bugs or security reasons. So basically no new development. If you have the ability to do so in your environment then I would recommend powershell. I do all new development that I can within my environment (we don't have it on all clients yet) in powershell.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|