Highlighted
mikeross1 Absent Member.
Absent Member.
12470 views

running batch file on login with bundle

Hello all,

I'm trying to have zcm run a batch file on every login (to change the wallpaper). My batch file is as such:

@echo off
call :quiet>nul 2>&1
goto :EOF
:quiet
:: Configure Wallpaper
REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "\\files\data\public\wswallpaper.bmp"
REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 2
REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D 0
:: Make the changes effective immediately
%SystemRoot%\System32\RUNDLL32.EXE User32.dll,UpdatePerUserSystemParameters


The batch file works great when double-clicked, but I can't seem to get the right configuration for the bundle. It downloads the file to the client via zcm, but never runs it. Here's my bundle config:

Script to run: Select from this device
Select from this device: test.bat (\\files\data\public\test.bat)
Path to script engine: C:\WINDOWS\system32\cmd.exe
When action is complete
Working directory: C:\
It's set to Run Once for Every user that logs in

Workstations are windows xp.
ZCM 10.2.1

I also tried doing this through group policy but had problems with it not running on login as specified. Does anyone have any ideas as to what the best solution is and how my current bundle setup may not be working? Thanks!
Labels (2)
0 Likes
22 Replies
Micro Focus Expert
Micro Focus Expert

Re: running batch file on login with bundle

Make sure it's set to run as the Logged on User and not DynamicAdmin or
System.

On 3/23/2010 10:16 AM, mikeross wrote:
>
> Hello all,
>
> I'm trying to have zcm run a batch file on every login (to change the
> wallpaper). My batch file is as such:
>
> @echo off
> call :quiet>nul 2>&1
> goto :EOF
> :quiet
> :: Configure Wallpaper
> REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D
> "\\files\data\public\wswallpaper.bmp"
> REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D
> 2
> REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D
> 0
> :: Make the changes effective immediately
> %SystemRoot%\System32\RUNDLL32.EXE
> User32.dll,UpdatePerUserSystemParameters
>
>
> The batch file works great when double-clicked, but I can't seem to get
> the right configuration for the bundle. It downloads the file to the
> client via zcm, but never runs it. Here's my bundle config:
>
> Script to run: Select from this device
> Select from this device: test.bat (\\files\data\public\test.bat)
> Path to script engine: C:\WINDOWS\system32\cmd.exe
> When action is complete
> Working directory: C:\
> It's set to Run Once for Every user that logs in
>
> Workstations are windows xp.
> ZCM 10.2.1
>
> I also tried doing this through group policy but had problems with it
> not running on login as specified. Does anyone have any ideas as to
> what the best solution is and how my current bundle setup may not be
> working? Thanks!
>
>


0 Likes
mikeross1 Absent Member.
Absent Member.

Re: running batch file on login with bundle

craig_wilson;1951628 wrote:
Make sure it's set to run as the Logged on User and not DynamicAdmin or
System.

On 3/23/2010 10:16 AM, mikeross wrote:
>
> Hello all,
>
> I'm trying to have zcm run a batch file on every login (to change the
> wallpaper). My batch file is as such:
>
> @echo off
> call :quiet>nul 2>&1
> goto :EOF
> :quiet
> :: Configure Wallpaper
> REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D
> "\\files\data\public\wswallpaper.bmp"
> REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D
> 2
> REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D
> 0
> :: Make the changes effective immediately
> %SystemRoot%\System32\RUNDLL32.EXE
> User32.dll,UpdatePerUserSystemParameters
>
>
> The batch file works great when double-clicked, but I can't seem to get
> the right configuration for the bundle. It downloads the file to the
> client via zcm, but never runs it. Here's my bundle config:
>
> Script to run: Select from this device
> Select from this device: test.bat (\\files\data\public\test.bat)
> Path to script engine: C:\WINDOWS\system32\cmd.exe
> When action is complete
> Working directory: C:\
> It's set to Run Once for Every user that logs in
>
> Workstations are windows xp.
> ZCM 10.2.1
>
> I also tried doing this through group policy but had problems with it
> not running on login as specified. Does anyone have any ideas as to
> what the best solution is and how my current bundle setup may not be
> working? Thanks!
>
>

Hmm, I just tried that and it's still the same problem. It downloads the file (I see it on the desktop since I chose for it to be displayed there) but the file doesn't run. Am I maybe missing some options? I don't currently have anything in script parameters or script engine parameters, though I didn't think I needed any.
0 Likes
Micro Focus Expert
Micro Focus Expert

Re: running batch file on login with bundle

/c for Parameters

> Hmm, I just tried that and it's still the same problem. It downloads
> the file (I see it on the desktop since I chose for it to be displayed
> there) but the file doesn't run. Am I maybe missing some options? I
> don't currently have anything in script parameters or script engine
> parameters, though I didn't think I needed any.
>
>


0 Likes
mikeross1 Absent Member.
Absent Member.

Re: running batch file on login with bundle

I couldn't get the batch file to run on the client PC from "Select from this device", but I got it working using "Define your own script". However, I still have a problem:

The script only runs once. It will only run again on the same machine if I take it out of the bundle group and then add it back in. Restarting the machine and logging off/on has no effect.

Under "Assignment Details" in the Relationships tab I have the distribution schedule set for User Login and Install immediately after distribution and Launch immediately after installation.

I have runonce disabled. So why's it only running once. Any ideas? Thanks!
0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: running batch file on login with bundle

mikeross;1952854 wrote:
I couldn't get the batch file to run on the client PC from "Select from this device", but I got it working using "Define your own script". However, I still have a problem:

The script only runs once. It will only run again on the same machine if I take it out of the bundle group and then add it back in. Restarting the machine and logging off/on has no effect.

Under "Assignment Details" in the Relationships tab I have the distribution schedule set for User Login and Install immediately after distribution and Launch immediately after installation.

I have runonce disabled. So why's it only running once. Any ideas? Thanks!


Move the script action from install tab to launch tab and set it to launch at user login.

Thomas
0 Likes
Micro Focus Expert
Micro Focus Expert

Re: running batch file on login with bundle

Use "Launch", not "Distribution Schedule" and make sure the Batch file
is defined under the "Launch" tab.

On 3/25/2010 2:56 PM, mikeross wrote:
>
> I couldn't get the batch file to run on the client PC from "Select from
> this device", but I got it working using "Define your own script".
> However, I still have a problem:
>
> The script only runs once. It will only run again on the same machine
> if I take it out of the bundle group and then add it back in. Restarting
> the machine and logging off/on has no effect.
>
> Under "Assignment Details" in the Relationships tab I have the
> distribution schedule set for User Login and Install immediately after
> distribution and Launch immediately after installation.
>
> I have runonce disabled. So why's it only running once. Any ideas?
> Thanks!
>
>


0 Likes
mikeross1 Absent Member.
Absent Member.

Re: running batch file on login with bundle

New information:

The bundle installs on the client machine, it just only launches once. Is anyone else having problems with bundles not launching?
0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: running batch file on login with bundle

mikeross;1952873 wrote:
New information:

The bundle installs on the client machine, it just only launches once. Is anyone else having problems with bundles not launching?


Take a look at the previous posts by Craig and me, this will get your bundle launching everytime.

Thomas
0 Likes
mikeross1 Absent Member.
Absent Member.

Re: running batch file on login with bundle

Thanks for the help! However, I'm still having trouble. I added the User Login Event to the Launch schedule in Relationships > Assignment Details, but it still doesn't launch the script more than once. I didn't see a place to define the batch file in the Launch tab. The only place I know of to define the batch file is Actions > Launch. Maybe I'm looking in the wrong place?
Sorry to keep asking you guys, but the documentation doesn't get this detailed, so I'm kind of stuck!
0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: running batch file on login with bundle

mikeross;1952881 wrote:
Thanks for the help! However, I'm still having trouble. I added the User Login Event to the Launch schedule in Relationships > Assignment Details, but it still doesn't launch the script more than once. I didn't see a place to define the batch file in the Launch tab. The only place I know of to define the batch file is Actions > Launch. Maybe I'm looking in the wrong place?
Sorry to keep asking you guys, but the documentation doesn't get this detailed, so I'm kind of stuck!


When you go into the bundle and under actions you have different "sub-tabs" install/launch/... Put the script as an action under the launch tab.

Thomas
0 Likes
mikeross1 Absent Member.
Absent Member.

Re: running batch file on login with bundle

Gotcha - yep, it's already there. I have it set as a "Define your own script". I think if I didn't have it there it wouldn't run at all, but it runs once so I know the script works in the Action tab.
0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: running batch file on login with bundle

mikeross;1952885 wrote:
Gotcha - yep, it's already there. I have it set as a "Define your own script". I think if I didn't have it there it wouldn't run at all, but it runs once so I know the script works in the Action tab.


Somewhere at the bundle level/settings/relations it's set to launch once, because I have many bundles that is set to launch at user login and they work perfectly every time a user logs in.

I'm not in front of a zcm server right now so I can't point you to the right tabs a settings from memory, sry. I'll be in front of a zcm server in about 12 hours, so if you haven't found the correct settings by then I will look it up for you.

Thomas
0 Likes
mikeross1 Absent Member.
Absent Member.

Re: running batch file on login with bundle

thsundel;1952897 wrote:
Somewhere at the bundle level/settings/relations it's set to launch once, because I have many bundles that is set to launch at user login and they work perfectly every time a user logs in.

I'm not in front of a zcm server right now so I can't point you to the right tabs a settings from memory, sry. I'll be in front of a zcm server in about 12 hours, so if you haven't found the correct settings by then I will look it up for you.

Thomas

It's working! Thanks for all your help. Here are the settings I used in case anyone else is wondering:

Created a new directive bundle. In the Action tab, under the Launch section, I added a Run Script with the following settings:

Define Your Own Script
Script File Extension: .bat
Path to Script Engine: C:\WINDOWS\System32\cmd.exe
Script Engine Parameters: /c
When Action is Complete
Working directory: C:\
Priority High
Run as User

Then in Relationships, I added the device and in Assignment details (on the right), used the following settings:

Distribution Schedule: User login (didn't check any of those menu options because then the script would only run once, even if I had the Launch Schedule set correctly)
Launch Schedule: Zenworks Login (Only ran once for me if it was set to user login)

Once I added the device to the bundle relationships, I still had to refresh the computer's policies before it would appear in the client's zcm agent list (unless I wanted to wait for the auto refresh every 12 hours,ugh). I refreshed these policies by going to Devices > Workstations > check mark the device then at the top choose options > refresh policies.

Then it works! Wow, that seems like a lot to do for a simple batch file to run at startup. Anyway, thanks. You helped a lot!
0 Likes
mikeross1 Absent Member.
Absent Member.

Re: running batch file on login with bundle

Whoops, I meant that I go to Devices > Workstations > check mark the device then at the top choose Quicktasks > refresh policies.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.