Jump to content

RunAsSet and netsh commands...


smooter
 Share

Recommended Posts

Hey folks,

I am NOT much of a "scripter" nor a "programmer" by any stretch of the imagination, but I have read a TON of info on this issue, and I though I had it figured out, but it still isn't working.

My script:

-----

;===============================================================================

;

; Description: Enable File/Print Sharing on Windows Desktops to support KBOX Agent deployment.

; Syntax: None

; Parameter(s): None

; Requirement(s): None

; Return Value(s): None

;

; Author(s):

; Note(s):

;===============================================================================

RunAsSet("username", "domainname", "password")

MsgBox(0, "UserSuccess", "Authenticated")

RunWait(@ComSpec & " /c " & '"netsh firewall set service type = FILEANDPRINT Mode = ENABLE "',"",@SW_SHOW)

MsgBox(0,"It Finished", "Congrats!")

------

The first MsgBox comes up, so I am pretty sure the authentication is successful.

Before the second can come up I get the following error message:

Line 0 (file "c:\utilities\firewall.exe"):

RunWait(@ComSpec & " /c " & '"netsh firewall set service type = FILEANDPRINT Mode = ENABLE "',"",@SW_SHOW)

Error: Unable to execute the external program.

The directory name is invalid.

I should also point out that I have tried to convert a VBS script to AutoIt and had no luck, pretty much the same error, and I am compiling these into an EXE so I don't have to worry about the username/password being accessible.

Thanks for your help!

sm00ter

Link to comment
Share on other sites

$result = RunWait(@ComSpec & " /c netsh firewall set service type = FILEANDPRINT Mode = ENABLE ","",@SW_SHOW)

MsgBox(0,"",$result)

Command line programs generally return zero on success. This worked for me.

Edited by weaponx
Link to comment
Share on other sites

$result = RunWait(@ComSpec & " /c netsh firewall set service type = FILEANDPRINT Mode = ENABLE ","",@SW_SHOW)

MsgBox(0,"",$result)

Command line programs generally return zero on success. This worked for me.

Urrgh!

Thanks for the post weaponx, but it still gives me the "Unable to execute the external program. Directory name is invalid".

This crap is killing me!

Thanks,

smooter

Link to comment
Share on other sites

First, I think if you set the default directory to @SystemDir, your original command line would work:

RunWait(@ComSpec & " /c " & '"netsh firewall set service type = FILEANDPRINT Mode = ENABLE "',@SystemDir,@SW_SHOW)oÝ÷ Øz0z÷«Â+aֺѺu×(f§vX§x¥Á¬¬)¶ë.­â$-!jجm觬±ç[ÉéÜ"§ÊØbajÓtáj÷·uçl¥§³­«¨µë,¢Ø^FéÖj+p¢é]$)¶¬jëh×6RunWait ( '"' & @ComSpec & '" /c "' & @SystemDir & '\netsh.exe" firewall set service type = FILEANDPRINT Mode = ENABLE' )oÝ÷ ØßiË_¢·²'«µë-xßÙeºË²È Ø^r¦jwm¡«Ú®&ë(Ýý±æ¢z»h¾'°jëh×6$Cmd = '"' & @ComSpec & '" /c "' & @SystemDir & '\netsh.exe" firewall set service type = FILEANDPRINT Mode = ENABLE'
MsgBox ( 0, @ScriptName, $Cmd, 3 )

I'll admit, enclosing @ComSpec and @SystemDir in double quotes is obsessive as I've NEVER seen either environment variable have spaces, but you never know when some wanker decides to be cute and make the Windows directory "My Windows"!

I went through MONTHS of debate with someone here because a utility they wrote worked perfectly fine for them, but would not work for me at all. I kept trying to explain that the problem was that a call to run a program was failing because there were no double quotes in the Run command line, but I failed to communicate it well enough (there was also a language barrier), and it wasn't until it came to light that his installation of Windows use C:\Programs instead of C:\Program Files that he was able to understand the problem!!!

Ever since then, I make sure everything in a Run/RunWait command is quoted so that there's no possibility of an error there! I have plenty of other places to introduce errors!!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...