Sign in to follow this  
Followers 0
A.B.Ames

Quotes around variables in cmdline & docs Sample

3 posts in this topic

#1 ·  Posted (edited)

Hi all,

2 sample lines that may help those new here.

90% of you don't need this but I would like to post it for those that, like me are new and having headaches getting it to work. The manual covers basic quote use but I found using with variables and switches difficult. Online searching had lots of info for quotes but couldn't find any that seemed to cover these situations exactly. So after trial and error I got these to work, hopefully this will help out other newbies.

If you just want to run this in command line:

hlscan /dir "E:\_TEMP\HL test" /log

the path is the variable

and here is a sample that worked:

$hlscanCmd = RunWait(@COMSPEC & ' /c hlscan /dir "' & $SearchPath & '" /log',"",@SW_HIDE)

(corrected thx to Saunders reply -ABA)

write a line to batch file

rd /s /q "C:\Documents and Settings\JohnDoe"

JohnDoe is the Variable

and here is a sample that worked:

FileWriteLine($VarBatch, 'rd /s /q "C:\Documents and Settings\' & $VarUser & '"')

If any errors please let me know,

else - hope this helps someone

Thx

A.B.Ames

Edited by A.B.Ames

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Why start a string with the double quotes at all?

$hlscanCmd = RunWait(@COMSPEC & " /c" & 'hlscan /dir "' & $VarPath & '" /log',"",@SW_HIDE)

To

$hlscanCmd = RunWait(@COMSPEC & ' /c hlscan /dir "' & $VarPath & '" /log',"",@SW_HIDE)

Also note, in your first example you didn't put a space between /c and hlscan.

" /c" & 'hlscan' = /chlscan

I don't know that the command line understands that parameter :idiot:

Edited by Saunders

Share this post


Link to post
Share on other sites

Hi Saunders,

Thx for the corrections they make much better sense, as for why I did it that way i can only answer that I'm learning and don't fully understand it all yet. The examples of Quotes in the manual only deal with text and I couldn't locate any similar to what i was doing. So I pieced together what i could and then did trial and error till it worked. Infomation I found seemed to be more oriented for those that already know programming and scripting, not much for those that are learning.

Also I'm not sure why the code funtions with out a space after /c, again what you showed me same makes far more sense (and i will follow that now). Oddly enough though, I have done dozens of scripts using lines without the space and using many prompt commands (Net User, Net Localgroup, etc.) and they have all worked so i never bothered to change it.

again, many thx

Take Care

A.B.Ames

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0