compdigit44
asked on
Problems running Script via SCCM 2007 R3
I'm trying to push out a script via SCCM 2007 R3 that will remove a link from "ALL Users" Start Menu. If I run the script locally is works perfectly. When I runs via SCCM the shortcut is not removed from the start menu. I believe SCCM is getting comfused as to teh correct working directory to run the script again. I have tried using the PUSHD command but nothing seems to be workings. I have been on this for days which is driving me crazy because it shold be so simple.
Here is a sample of my script below...
pushd c:\
erase /F /Q "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\Prog ram123.lnk "
Here is a sample of my script below...
pushd c:\
erase /F /Q "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\Prog
Are you running it as SYSTEM for the environment? You shouldn't need pushd, that's for network drives.
ASKER
I'm not the SCCM admin how can I check this?
First of all, your script will work only on XP machines because on Win7 "Documents and settings" don't exist. I would suggest you that you create VBScript for this.
Check execmgr.log in C:\windows\system32\ccm\lo gs
If it is being run as SYSTEM, it should say something like:
Executing program deletesht.cmd in Admin context execmgr 10/4/2011 2:33:46 PM 268 (0x010C)
If it is being run as SYSTEM, it should say something like:
Executing program deletesht.cmd in Admin context execmgr 10/4/2011 2:33:46 PM 268 (0x010C)
ASKER
Yes it's running under NT Authority /System
Hmm, I'm out of ideas. I looked at my own scripts and I use the same syntax, except I use "del" instead of "erase", but that shouldn't matter. Hopefully the other experts have some ideas.
ASKER
It's very strange and driving me crazy I to tried using the "del" command but got the same results.. :-(
If you had logging in your script, it would help to tell you the nature of the error.
Here, use my VB script I've setup for you. It will query the OS to set the right variable for the startmenu for XP or win7 enterprise (you can edit this in the code if you want - just look at sub oscheck), it will then check if the file exists, and if it does it will delete it. at every stage of the script, it logs its actions and error outputs to a log file. The log file is the exact same name of the script so rename the script to something you would like. it puts the log file in C:\windows\temp.
oh btw for some reason the caption for "Microsoft Windows 7 Enterprise " has a space behind it because thats how microsoft put it in the reg.
Delete-StartMenu-Shortcut.vbs
Here, use my VB script I've setup for you. It will query the OS to set the right variable for the startmenu for XP or win7 enterprise (you can edit this in the code if you want - just look at sub oscheck), it will then check if the file exists, and if it does it will delete it. at every stage of the script, it logs its actions and error outputs to a log file. The log file is the exact same name of the script so rename the script to something you would like. it puts the log file in C:\windows\temp.
oh btw for some reason the caption for "Microsoft Windows 7 Enterprise " has a space behind it because thats how microsoft put it in the reg.
Delete-StartMenu-Shortcut.vbs
oh and to use the script in SCCM, create a package with the script in the source, then use this to call the script in the program:
cscript.exe Delete_StartMenu_Shortcut. vbs
cscript.exe Delete_StartMenu_Shortcut.
ASKER
Thanks I try it and let you konw how I make out. I noticed in SCCM there is a setting for the package to require a drive letter. For kicks I changed this from run from UNC to require a drive letter and I selected C..
no no no.... you have now told it that the source for your script is on C:
that option is for the source on your distribution points. unless you have 2 volumes with package source and the same share names, its not a good idea to use drive letters.
If you still would like to test out your own bat file, then put your program like this:
cmd /c yourscript.bat
set the advertistment to download before running and make it run with admin rights. you can try ticking and unticking the option of whether its interactive or not as this can sometimes play with scripts.
when you say it was not working, were you getting an error code in your advertisment status or were you just checking to see if the link was still there?
that option is for the source on your distribution points. unless you have 2 volumes with package source and the same share names, its not a good idea to use drive letters.
If you still would like to test out your own bat file, then put your program like this:
cmd /c yourscript.bat
set the advertistment to download before running and make it run with admin rights. you can try ticking and unticking the option of whether its interactive or not as this can sometimes play with scripts.
when you say it was not working, were you getting an error code in your advertisment status or were you just checking to see if the link was still there?
ASKER
How can I download the advertisment before loading
Just want to add something.
You can create package without source files and then in program just call:
You can create package without source files and then in program just call:
cscript.exe \\servername\share\script.vbs
If is this solution please do not split points and accept Kezzi's post only.
on your advertisment on the Distribution Points tab is the setting to allow you to download the source data locally to your CCM cache before running the program.
ASKER
My advertise is set to download source data locally also I added the follow to the first line of my batch file chdir %~dp0 and re-ran the adveristment. The package but did not remove the shortcut yet againit works fine if I double click on the batch file. This is do frustrating
ASKER
I forgot to mention I'm not getting any errors in SCCM. As far as SCCM in concerned the package install correctly with out error. I only know if doesn't becuase my shortcut isn't removed
And this is on WinXP machine? Or Win7?
ASKER
should I try to reread the distrubiotn point since I've update my script?
ASKER
It happens on both XP and Windows 7
Always, after modifications you must update distribution point. And rerun advertisment.
ASKER
i didn't know that I will try it now...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok I will try that command now and let you know. How does this differ from the command I am using?
del or erase does not matter. But with the posted command line it's started within a seperate dos box
Oh forgot a quote (") at the end.
Do you execute the command within a batch file or direct in the command line of the program / task sequence?
Oh forgot a quote (") at the end.
Do you execute the command within a batch file or direct in the command line of the program / task sequence?
ASKER
the command is executed within a batch file that is pushe dout vis SCCM. I just updated the batch file updated the distrubution point and re-running the advertisement again.
I will keep you posted
I will keep you posted
ASKER
This command did the trick!!!!!!!!!!!1