Solved

VBScript ShellExecute RUNAS - parameters with spaces

Posted on 2012-03-29
2
3,962 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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 pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 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