Jump to content
Sign in to follow this  
supergian

Task to run a bat: it ends successfully, but without the expected result [In progress]

Recommended Posts

Hello, i have created this bat file:

 

@echo off

:: Disattiva gestione stampante predefinita automatica

REG ADD "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" /V LegacyDefaultPrinterMode /T REG_dWORD /D 1 /F

 

it turns off the damn automatic management of the default printer in Windows 10.

If i run maually on the client, it works but if i create an installation package with this bat file and i run an installation task with that package, the task ends without errors but the printers option remain unchanged (i use KSC 10 Sp2 patch A).

 

I have also this bat:

@echo off

:: Disattiva avvio rapido

REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /V HiberbootEnabled /T REG_dWORD /D 0 /F

 

It turns off the fast startup on windows 10/8.

This works perfectly.

does anyone know why?

Share this post


Link to post

Hi,

 

Did you use the same account for both these tasks?

After you've run first batch file, is there change at registry?

 

BR

Share this post


Link to post
Hi,

 

Did you use the same account for both these tasks?

After you've run first batch file, is there change at registry?

 

BR

Yes the same acount.

In the Account task settings of both tasks i have "no account required (Network Agent Installed)".

No, there in no change in the registry key it remain on "0" that menas activated. "1" means disabled.

 

 

Share this post


Link to post

Long story short:

You try to change registry of currently logged on user, am I right?

Network Agent runs under SYSTEM account, with your batch you change registry setting of SYSTEM account and not for logged on user.

 

-- will read user and convert it to sid --

@echo off

for /f "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq explorer.exe" /FO LIST /V') do if /i "%%a %%b"=="User Name:" set

 

_currdomain_user=%%c

for /f "TOKENS=1,2 DELIMS=\" %%a in ("%_currdomain_user%") do set _currdomain=%%a & set _curruser=%%b

for /f "TOKENS=2 DELIMS= " %%c in ('whoami /user ^| find /i "%_curruser%"') do set _currusersid=%%c

echo %_currusersid%

-- end --

 

then:

REG ADD "HKEY_USERS\<SIDOUTPUT from batch>\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" /V LegacyDefaultPrinterMode /T REG_dWORD /D 1 /F

 

 

Share this post


Link to post
Long story short:

You try to change registry of currently logged on user, am I right?

Network Agent runs under SYSTEM account, with your batch you change registry setting of SYSTEM account and not for logged on user.

 

-- will read user and convert it to sid --

@echo off

for /f "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq explorer.exe" /FO LIST /V') do if /i "%%a %%b"=="User Name:" set

 

_currdomain_user=%%c

for /f "TOKENS=1,2 DELIMS=\" %%a in ("%_currdomain_user%") do set _currdomain=%%a & set _curruser=%%b

for /f "TOKENS=2 DELIMS= " %%c in ('whoami /user ^| find /i "%_curruser%"') do set _currusersid=%%c

echo %_currusersid%

-- end --

 

then:

REG ADD "HKEY_USERS\<SIDOUTPUT from batch>\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" /V LegacyDefaultPrinterMode /T REG_dWORD /D 1 /F

It looks great but...i"m not a script expert.

Have i to copy this code in the bat file as well as?

 

Share this post


Link to post

Yes sure, but excuse I'm not the script spoon feeder!

You have to help yourself by combining the fromer suggestions.

Good luck, have a nice week.

Share this post


Link to post
Sign in to follow this  

×
×
  • Create New...

Important Information

We use cookies to make your experience of our websites better. By using and further navigating this website you accept this. Detailed information about the use of cookies on this website is available by clicking on more information.