Solved

VBScript ShellExecute RUNAS - parameters with spaces

Posted on 2012-03-29
2
3,546 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 50 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now