Solved

VBScript ShellExecute RUNAS - parameters with spaces

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

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 article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

763 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