Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VBScript ShellExecute RUNAS - parameters with spaces

Posted on 2012-03-29
2
Medium Priority
?
4,270 Views
Last Modified: 2012-03-30
Hi folks,

I have been working on this one for a while and I just can't seem to get it.  What am I doing wrong?  I could explain what I am trying to do and why I am trying to do it, but in this forum, I am sure you folks get the gist.  The problem exists with the spaces in the HKLM entry.

Please - dont ask why, dont ask how, dont recommend another method.. My question is just about my syntax.   Sorry if I come across a bit direct, but sometimes that happens  :) Thanks in advance!!

'On Error Resume Next 

Set objShell = CreateObject("Shell.Application")

strWinLogon = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon"
strRegApp = "C:\WINDOWS\system32\reg.exe"
strArg = "test"


'objshell.shellexecute strRegApp, Chr(34) & strWinLogon & Chr(34) & " /v bb /t REG_SZ /d " & strArg & " /f","", "runas", 1 

objShell.ShellExecute "reg.exe", Chr(34) & strWinLogon & Chr(34) & " /v tstval /t REG_SZ /d test", "", "runas", 1


wscript.echo "Done"


    WScript.Quit

Open in new window


Regards,
RichS
0
Comment
Question by:dcjsdts
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 200 total points
ID: 37785075
Hi, you're missing the "add" in the arguments to reg.exe

It should be
objShell.ShellExecute "reg.exe", "add " & Chr(34) & strWinLogon & Chr(34) & " /v tstval /t REG_SZ /d test", "", "runas", 1


Regards,

Rob.
0
 

Author Closing Comment

by:dcjsdts
ID: 37786561
A HUGE DUH to me.   Thank you!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question