Solved

VBScript ShellExecute RUNAS - parameters with spaces

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

822 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