smooter Posted December 28, 2007 Share Posted December 28, 2007 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 More sharing options...
weaponx Posted December 28, 2007 Share Posted December 28, 2007 (edited) $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 December 28, 2007 by weaponx Link to comment Share on other sites More sharing options...
smooter Posted December 31, 2007 Author Share Posted December 31, 2007 $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 More sharing options...
MHz Posted December 31, 2007 Share Posted December 31, 2007 Try using a working directory that is permissive for the RunAsSet user.i.e.RunWait(@ComSpec & " /c " & '"netsh firewall set service type = FILEANDPRINT Mode = ENABLE "', @TempDir, @SW_SHOW) Link to comment Share on other sites More sharing options...
JerryD Posted December 31, 2007 Share Posted December 31, 2007 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now