Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - right click option to run a scipt without closing the window when done?

Reply
 
Old 08-26-2008   #1 (permalink)
Steve


 
 

right click option to run a scipt without closing the window when done?

I tried adding the following as a custom right-click command (via folder
options) but I keep getting access denied permission errors (with the file
path and name in the error text) when trying to run it via a right click on
a vbs file:
%SystemRoot%\system32\cmd.exe /k C:\WINDOWS\System32\CScript.exe "%1"

Which should resolve to something like this at runtime (which runs fine at
the command prompt by the way):
c:\windows\system32\cmd.exe /k C:\WINDOWS\System32\CScript.exe "C:\Documents
and Settings\Steve\Desktop\example.vbs"

The default "Open with command prompt" just runs the vbs and then exits, I
want the window the remain open when done. The /k tells the command window
to stay open when done (so you can read the output, etc).

Q: Any ideas why this isn't working, or how to get the desired action?

Tested using XP-Pro SP2. I can provide a screen cap of the dialog if you
need the visual.



My System SpecsSystem Spec
Old 08-26-2008   #2 (permalink)
James Whitlow


 
 

Re: right click option to run a scipt without closing the window when done?

"Steve" <sdixon2006@xxxxxx> wrote in message
news8Nsk.117438$nD.12944@xxxxxx
Quote:

>I tried adding the following as a custom right-click command (via folder
>options) but I keep getting access denied permission errors (with the file
>path and name in the error text) when trying to run it via a right click on
>a vbs file:
> %SystemRoot%\system32\cmd.exe /k C:\WINDOWS\System32\CScript.exe "%1"
>
> Which should resolve to something like this at runtime (which runs fine at
> the command prompt by the way):
> c:\windows\system32\cmd.exe /k C:\WINDOWS\System32\CScript.exe
> "C:\Documents and Settings\Steve\Desktop\example.vbs"
>
> The default "Open with command prompt" just runs the vbs and then exits, I
> want the window the remain open when done. The /k tells the command
> window to stay open when done (so you can read the output, etc).
>
> Q: Any ideas why this isn't working, or how to get the desired action?
>
> Tested using XP-Pro SP2. I can provide a screen cap of the dialog if you
> need the visual.
Try creating a shortcut in the 'SendTo' folder without specifying the
'%1' argument.

The code below should create the item for you. It works on my comptuer &
I am also using XP-Pro SP2.

Set oWSH = CreateObject("WScript.Shell")
sSendTo = oWSH.Environment("Process").Item("UserProfile") & "\SendTo\"
With oWSH.CreateShortcut(sSendTo & "Run With CScript.lnk")
.TargetPath = "%SystemRoot%\system32\cmd.exe"
.Arguments = "/k %systemroot%\system32\cscript.exe //NoLogo"
.WorkingDirectory = "%temp%"
.Description = "Run VBScript with CScript & leave window open."
.IconLocation = "%systemroot%\system32\cscript.exe, 0"
.Save
End With


My System SpecsSystem Spec
Old 08-27-2008   #3 (permalink)
Al Dunbar


 
 

Re: right click option to run a scipt without closing the window when done?


"Steve" <sdixon2006@xxxxxx> wrote in message
news8Nsk.117438$nD.12944@xxxxxx
Quote:

>I tried adding the following as a custom right-click command (via folder
>options) but I keep getting access denied permission errors (with the file
>path and name in the error text) when trying to run it via a right click on
>a vbs file:
> %SystemRoot%\system32\cmd.exe /k C:\WINDOWS\System32\CScript.exe "%1"
>
> Which should resolve to something like this at runtime (which runs fine at
> the command prompt by the way):
> c:\windows\system32\cmd.exe /k C:\WINDOWS\System32\CScript.exe
> "C:\Documents and Settings\Steve\Desktop\example.vbs"
>
> The default "Open with command prompt" just runs the vbs and then exits, I
> want the window the remain open when done. The /k tells the command
> window to stay open when done (so you can read the output, etc).
>
> Q: Any ideas why this isn't working, or how to get the desired action?
>
> Tested using XP-Pro SP2. I can provide a screen cap of the dialog if you
> need the visual.
I'd suggest using ASSOC and FTYPE to define a new "type" of file, and
associate this with a batch script that runs the script as vbscript and then
executes a PAUSE statement.

/Al


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Single Click option Tutorials
closing a window when done .NET General
CMD window now closing Vista General
closing wlm in tray w/r-click, then have to reboot to get back into wlm Live Mail
Closing window Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46