Startup scripts are great. They enable us to do configuration and customization on devices which improves end user experience. In this post, I’ll show how to publish startup scripts to devices with Intune.
An important path for this is “%SYSTEMDRIVE%\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\”. Placing any script or even program in this directory, will launch it at startup for any user logging on to that computer.
Taking advantage of this, we can make a script which writes to a file in that particular directory. As an example, I’ll write to a vbs-file in the StartUp-directory to make messageboxes appear at startup.
'Declaring variables Set objFSO=CreateObject("Scripting.FileSystemObject") Dim objWShell Set objWShell = WScript.CreateObject("WScript.Shell") Dim systemdrive 'Creating a new vbs-file in startup systemdrive = objWShell.expandEnvironmentStrings("%SYSTEMDRIVE%") File = systemdrive + _ "\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\HelloWorld.vbs" Set objFile = objFSO.CreateTextFile(File,True) 'Writing to the file whichever VBScript-script we want on startup objFile.Write "WScript.Echo _ ""Hello world! This is a startup script published with Intune.""" & vbCrLf objFile.Write "WScript.Echo _ ""And this is a second messagebox!""" & vbCrLf 'Closing the file objFile.Close
Save this as a vbs-file and wrap it to an exe with Windows’ built-in IExpress, calling cscript.exe to run the vbs-file. Finally, publish the exe-file with Intune.
Easy and simple trick for better management of devices with Intune!