Sign in to follow this  
Followers 0
mcbuddah

Trouble with Quotes

7 posts in this topic

I have searched through posts and the FAQ and I'm not understanding how to correctly do this.

I am attempting to add a printer to a computer using the command line and a VB code that comes with WinXP. The command that needs to be typed in and sent contains quotes, and these quotes are needed for the command to run successfully.

Here is the code:

Send("cscript prnmngr.vbs -a -p "printer name" -m "driver model" -r IP Address")

At this point the command prompt is open and in the correct directory, its just a matter of sending the right commands now.

The quotes around the printer name and driver model must be present. I can't get this to work for the life of me.

I have a feeling there is a simple solution I am missing. :D

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

*trying not to be rude* your quotes are all fucked up, to put it quick, replace the first and last quotes in your string with single quotes and that should fix it.

see the faq #7

oh, and why not do it as a run command?

runwait(@comspec & ' /c cscript prnmngr.vbs -a -p "printer name" -m "driver model" -r IP Address')
(disclaimer, I have no idea of what your command options should be, but this should be sound in theory)

edit: added the helpful bit at the end

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Wow, thanks for the quick reply. Yes, I know my quotes are F*ed up. I just started with AutoIt last week and am still learning.

The reason I haven't run it as a run command is because the script file is in c:\windows\system32\. And as of yet I haven't learned any other way to get there besides using a send command.

The code you changed for me doesn't work, only because when the command is run it is in the default directory which in this case is C:\Documents and Settings\Administrator\Desktop\ , and I need to be in c:\windows\system32\ .

If there is a way to specify what directory to go to with the run command I would be all for it.

Edit: Well after a little snooping around in the Help File some more, I found the working directory option for the run command, and now it works. Thanks for your help Emmanual.

Edited by mcbuddah

Share this post


Link to post
Share on other sites

RunWait(@comspec & ' /c cscript prnmngr.vbs -a -p "printer name" -m "driver model" -r IP Address', @SystemDir)

Tip 1: Lookup the functions in the help file. (Run, RunWait)

Tip 2: You can search through the help file.

Share this post


Link to post
Share on other sites

Run and RunWait work the same as if you were typing them from a command prompt. Just put the path before the program name.

Run(@ComSpec & ' /c "c:\some directory\some other directory\program.exe" -switch1 -switch2:paramater')

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Wow, thanks for the quick reply. Yes, I know my quotes are F*ed up. I just started with AutoIt last week and am still learning.

The reason I haven't run it as a run command is because the script file is in c:\windows\system32\. And as of yet I haven't learned any other way to get there besides using a send command.

The code you changed for me doesn't work, only because when the command is run it is in the default directory which in this case is C:\Documents and Settings\Administrator\Desktop\ , and I need to be in c:\windows\system32\ .

If there is a way to specify what directory to go to with the run command I would be all for it.

Edit: Well after a little snooping around in the Help File some more, I found the working directory option for the run command, and now it works. Thanks for your help Emmanual.

you're welcome, glad to help. seriously, I had my issues with quotes in the beginning too.

"I'm not even supposed to be here today!" -Dante (Hicks)

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