Comos Posted July 20, 2013 Share Posted July 20, 2013 Hi All,Im using a little batch file for configuring a remote shell service for a specific account.The only problem is,that the password when wanted to leave as default by the batch (Admin) is somehow not set by the service and I have to do it manually then.Here is the code:echo Now configuring the Remote Shell Serviceecho Stopping the Servicesc stop RshSvcecho Enter the Password for Admin account or ENTER to leave it as Adminset /p adminpwd=:if "%adminpwd%"=="" set pwd=Adminif %errorlevel%==0 set pwd=%adminpwd%sc config RshSvc type= own obj= %computername%\Admin password= %pwd%echo Starting the servicesc start RshSvcAny idea where's the bug? Link to comment Share on other sites More sharing options...
jaclaz Posted July 20, 2013 Share Posted July 20, 2013 Any idea where's the bug?Cannot say if it is a bug, but usually with this kind of batches it is better to use "negative logic".@ECHO OFFSET Defaultpwd=Adminecho Now configuring the Remote Shell Serviceecho Stopping the Servicesc stop RshSvcecho Enter the Password for Admin account or ENTER to leave the default oneset /p adminpwd=Type password or press [ENTER] to leave the Default one.IF NOT DEFINED adminpwd SET adminpwd=%Defaultpwd%sc config RshSvc type= own obj= %computername%\Admin password= %adminpwd%echo Starting the servicesc start RshSvcjaclaz Link to comment Share on other sites More sharing options...
Yzöwl Posted July 20, 2013 Share Posted July 20, 2013 What happens if you change it like this:@echo offsetlocalecho=Now configuring the Remote Shell Serviceecho=Stopping the Servicesc stop RshSvcecho=Enter the Password for Admin account or ENTER to leave it as Adminset /p "adminpwd = "if not defined adminpwd (set adminpwd=Admin)sc config RshSvc obj= "Admin" password= "%adminpwd%"echo=Starting the servicesc start RshSvc Link to comment Share on other sites More sharing options...
HarryTri Posted July 20, 2013 Share Posted July 20, 2013 The %errorlevel% is of the previews "set pwd=Admin" command? Which is supposed to be the default password? Maybe the correct syntax would be "if "%adminpwd%"=="" set %adminpwd%=Admin"? I think that as it is writen if %adminpwd% is null it remains so and pwd becomes null also. Link to comment Share on other sites More sharing options...
Comos Posted July 20, 2013 Author Share Posted July 20, 2013 Thanks guys, I'll probe it ! 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